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'
}
Technical Explanation of script
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.
Disclaimer
While we strive for accuracy and reliability in sharing scripts and information, it’s crucial to thoroughly test scripts and changes in a controlled environment before implementing them in your production setup. If you’re uncertain about the functionality of a script or alteration, we strongly recommend independently verifying its validity before utilization. The team behind OxusGeek.com bears no liability or responsibility for any outcomes resulting from using these scripts.