Last active
February 28, 2022 20:00
-
-
Save wise-io/4012a01b051d3ae4497bab7069a9459a to your computer and use it in GitHub Desktop.
Silently Installs Microsoft Teams
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Installs Microsoft Teams (Machine-Wide) | |
param( | |
[switch]$x86 # Attempts to install 32-bit Teams regardless of architecture | |
) | |
# Determine architecture | |
if ($x86) { $Arch = 'x86' } | |
else { | |
switch ($env:PROCESSOR_ARCHITECTURE) { | |
'AMD64' { $Arch = 'x64' } | |
'x86' { $Arch = 'x86' } | |
'ARM64' { $Arch = 'arm64' } | |
default { throw "Teams package for OS architecture '$_' is not supported." } | |
} | |
} | |
$Installer = "$env:Temp\Teams_windows_$Arch.msi" | |
$DownloadURL = "https://teams.microsoft.com/downloads/desktopurl?env=production&plat=windows&arch=$Arch&managedInstaller=true&download=true" | |
try { | |
# Download Microsoft Teams | |
Invoke-WebRequest -Uri $DownloadURL -OutFile $Installer | |
# Install Microsoft Teams | |
Start-Process -Wait msiexec -ArgumentList "/i $Installer OPTIONS=`"noAutoStart=true`" ALLUSERS=1" | |
} | |
catch { throw $Error } | |
finally { Remove-Item $Installer -Force -ErrorAction Ignore } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment