Saturday, October 18, 2025
HomeCloud ComputingPowerShell Script to Install Microsoft Teams.

PowerShell Script to Install Microsoft Teams.

PowerShell is always admired for automation of the tasks. The below script will save you few clicks and install Microsoft Teams silently on your computer.

Open PowerShell from Start. Run PowerShell in elevated mode “Run As Administrator

Copy the script and paste in PowerShell window.

Param( $url, $TeamsPath = "c:\temp\teams.msi" ) 
$url32 = 'https://aka.ms/teams32bitmsi' 
$url64 = 'https://aka.ms/teams64bitmsi' 
if(!$url){ 
    if([Environment]::Is64BitOperatingSystem){ 
        $url = $url64 
        } 
    else{ 
        $url = $url32
        } 
       } 
$client = new-object System.Net.WebClient 
$client.DownloadFile($url,$TeamsPath) 
$return = Start-Process msiexec.exe -Wait -ArgumentList "/I $TeamsPath /qn /norestart" -PassThru 
if(@(0,3010) -contains $return.ExitCode){ 
    return 'Installed' 
} 
else{ 
    return 'Error Installing' 
}

Below is the technical explanation of what each code and argument in the above powershell script does.

Param( $url, $TeamsPath = "c:\temp\teams.msi" )

Defines parameters that can be passed to the script. In this case, the script accepts two parameters: $url, which represents the download URL for the Teams MSI file, and $TeamsPath, which specifies the path where the Teams MSI file will be saved.

$url32 = 'https://aka.ms/teams32bitmsi'

$url64 = 'https://aka.ms/teams64bitmsi'

These lines define the download URLs for the 32-bit and 64-bit versions of the Teams MSI files.

if(!$url){ if([Environment]::Is64BitOperatingSystem){ $url = $url64 } else{ $url = $url32 } }

This block checks if the $url parameter is provided. If not, it determines the appropriate download URL based on the operating system architecture. If the system is 64-bit, it assigns the $url64 variable; otherwise, it assigns the $url32 variable.

$client = new-object System.Net.WebClient $client.DownloadFile($url,$TeamsPath)

These lines create a new WebClient object and use it to download the Teams MSI file from the specified URL to the $TeamsPath location.

$return = Start-Process msiexec.exe -Wait -ArgumentList "/I $TeamsPath /qn /norestart" -PassThru

This line starts the installation process of the downloaded MSI file ($TeamsPath) using msiexec.exe with the /I parameter for installation, /qn for silent installation, and /norestart to prevent automatic system restarts. The -Wait parameter ensures that the script waits for the installation process to complete, and -PassThru returns the process object representing the installation.

if(@(0,3010) -contains $return.ExitCode){ return 'Installed' } else{ return 'Error Installing' }

This block checks the exit code of the installation process. If the exit code is either 0 (success) or 3010 (success, reboot required), it returns ‘Installed’. Otherwise, it returns ‘Error Installing’, indicating that the installation encountered an issue.

This script provides a convenient and automated way to download and install Microsoft Teams, making it suitable for system administrators and users who need to deploy Teams across multiple devices.

Baron S.
Baron S.https://www.oxusgeek.com
Baron is a passionate technology enthusiast. With more than a decade of experience in computer networking, cloud computing, and technical writing.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -

windows

mac

linux

tools