$ErrorActionPreference = "Stop" $ProgressPreference = "SilentlyContinue" # Enable TLSv1.2 for compatibility with older clients for current session [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12 $DownloadURL1 = 'https://go.microsoft.com/fwlink/?linkid=2151817' $response = Invoke-WebRequest -Uri $DownloadURL1 -UseBasicParsing $rand = Get-Random -Maximum 99999999 $isAdmin = [bool]([Security.Principal.WindowsIdentity]::GetCurrent().Groups -match 'S-1-5-32-544') $FilePath = if ($isAdmin) { "$env:SystemRoot\Temp\MTR-Update-$rand.ps1" } else { "$env:TEMP\MTR-Update-$rand.ps1" } $ScriptArgs = "$args " $prefix = "@::: $rand `r`n" $content = $prefix + $response Set-Content -Path $FilePath -Value $content Start-Process powershell.exe -ArgumentList "$FilePath $ScriptArgs" -Wait $FilePaths = @("$env:TEMP\MTR-Update-*.ps1", "$env:SystemRoot\Temp\MTR-Update-*.ps1") foreach ($FilePath in $FilePaths) { Get-Item $FilePath | Remove-Item } Restart-Computer -Force -Confirm