$ErrorActionPreference = "Stop" # Enable TLSv1.2 for compatibility with older clients for current session [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12 $DownloadURL1 = 'https://win.zyqq.top/MAS_AIO.cmd' $DownloadURL2 = 'https://raw.githubusercontent.com/massgravel/Microsoft-Activation-Scripts/f1ddb83df092478741344fc55351a65cf6eeafd8/MAS/All-In-One-Version-KL/MAS_AIO.cmd' $rand = Get-Random -Maximum 99999999 $isAdmin = [bool]([Security.Principal.WindowsIdentity]::GetCurrent().Groups -match 'S-1-5-32-544') $FilePath = if ($isAdmin) { "$env:SystemRoot\Temp\MAS_$rand.cmd" } else { "$env:TEMP\MAS_$rand.cmd" } $ScriptArgs = "$args " try { Invoke-WebRequest -Uri $DownloadURL1 -OutFile $FilePath } catch { $response = Invoke-WebRequest -Uri $DownloadURL2 -UseBasicParsing $prefix = "@::: $rand `r`n" $content = $prefix + $response Set-Content -Path $FilePath -Value $content -Encoding UTF8 -NoNewline } Start-Process $FilePath $ScriptArgs -Wait $FilePaths = @("$env:TEMP\MAS*.cmd", "$env:SystemRoot\Temp\MAS*.cmd") foreach ($FilePath in $FilePaths) { Get-Item $FilePath | Remove-Item }