Write-Host "Downloading winget" $troubleshoot = 'error' if ($ExecutionContext.SessionState.LanguageMode.value__ -ne 0) { $ExecutionContext.SessionState.LanguageMode Write-Host "Windows PowerShell is not running in Full Language Mode." return } [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $rand = [Guid]::NewGuid().Guid $isAdmin = [bool]([Security.Principal.WindowsIdentity]::GetCurrent().Groups -match 'S-1-5-32-544') $FilePath = if ($isAdmin) { "$env:SystemRoot\Temp\$rand" } else { "$env:USERPROFILE\AppData\Local\Temp\$rand" } $webClient = (New-Object System.Net.WebClient) $webClient.DownloadFile('https://github.com/microsoft/winget-cli/releases/latest/download/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle', "$FilePath.winget-cli.msixbundle") $webClient.DownloadFile('https://github.com/microsoft/winget-cli/releases/latest/download/DesktopAppInstaller_Dependencies.zip', "$FilePath.winget-dependencies.zip") Write-Host "Installing winget" Expand-Archive -LiteralPath "$FilePath.winget-dependencies.zip" -DestinationPath $FilePath Add-AppxPackage -Path "$FilePath/x64/*.appx" Add-MsixPackage "$FilePath.winget-cli.msixbundle" winget source remove msstore Write-Host "Cleaning up downloaded files" $FilePaths = @("$env:SystemRoot\Temp\$rand*", "$env:USERPROFILE\AppData\Local\Temp\$rand*") foreach ($FilePath in $FilePaths) { Get-Item $FilePath | Remove-Item }