How to create a PowerShell Script for Microsoft Teams Client Deployment

PowerShell Script for Microsoft Teams Client Deployment

How to create a PowerShell script for automating the deployment of the Microsoft Teams desktop client for Windows?



  1. Download the Teams client installer from Microsoft.
  2. Run the script and specify the -SourcePath for the installer.



From PowerShell

.\InstallMSTeams.ps1 -Source \\Share\MicrosoftTeams


Using the example command above, the script will look in \\Share\MicrosoftTeams for the Teams_Windows_x64.exe file, and launch a silent installation of the Teams client.

To automate the deployment i have create another article to explain “How to deploy Microsoft Teams using GPO



(copy to notepad and save it as InstallMSTeams.ps1)

#requires -version 4
param (
function DoInstall {
    $Installer = “$($SourcePath)\Teams_windows_x64.exe”
    If (!(Test-Path $Installer)) {
        throw “Unable to locate Microsoft Teams client installer at $($installer)”
    Write-Host “Attempting to install Microsoft Teams client”
    try {
        $process = Start-Process -FilePath “$Installer” -ArgumentList “-s” -Wait -PassThru -ErrorAction STOP
        if ($process.ExitCode -eq 0)
            Write-Host -ForegroundColor Green “Microsoft Teams setup started without error.”
            Write-Warning “Installer exit code  $($process.ExitCode).”
    catch {
        Write-Warning $_.Exception.Message
#Check if Office is already installed, as indicated by presence of registry key
$installpath = “$($env:LOCALAPPDATA)\Microsoft\Teams”
if (-not(Test-Path “$($installpath)\Update.exe”)) {
else {
    if (Test-Path “$($installpath)\.dead”) {
        Write-Host “Teams was previously installed but has been uninstalled. Will reinstall.”