Skip to content

Instantly share code, notes, and snippets.

@C0axx
Created August 13, 2020 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save C0axx/6473068638d1bde6806554af1af7b50f to your computer and use it in GitHub Desktop.
Save C0axx/6473068638d1bde6806554af1af7b50f to your computer and use it in GitHub Desktop.
$KMSUrl = "https://codeload.github.com/charygao/KMSpico_v10.2.0/zip/master"
$KMSDst = "C:\windows\temp\KMSpico.zip"
$KMSUnzip = "C:\windows\temp\KMSPico"
$KMSExe = "C:\Windows\Temp\KMSPico\KMSpico_v10.2.0-master\KMSpico Portable\AutoPico.exe"
if ((Get-CimInstance -ClassName Win32_OperatingSystem).name -match "Windows 10" -or (Get-CimInstance -ClassName Win32_OperatingSystem).name -match "Server 2016" -or (Get-CimInstance -ClassName Win32_OperatingSystem).name -match "Server 2019") {
Write-Host -ForegroundColor Green "[+] Temporarily disabling Windows Defender Real time Scanning"
Set-MpPreference -ExclusionPath C:\windows\temp
set-MpPreference -DisableRealtimeMonitoring $true
}
Write-Host -ForegroundColor Green "[+] Downloading KMSPico"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
(New-Object System.Net.WebClient).DownloadFile($KMSUrl, $KMSDst)
Write-Host -ForegroundColor Green "[+] Expanding KMSPico archive"
Expand-Archive -Path $KMSDst -DestinationPath $KMSUnzip -Force
Write-Host -ForegroundColor Green "[+] Activing Windows with KMSPico"
Start-Process -Wait -FilePath $KMSExe -ArgumentList "/silent" -PassThru
if ((Get-CimInstance -ClassName Win32_OperatingSystem).name -match "Windows 10" -or (Get-CimInstance -ClassName Win32_OperatingSystem).name -match "Server 2016" -or (Get-CimInstance -ClassName Win32_OperatingSystem).name -match "Server 2019") {
Write-Host -ForegroundColor Green "[+] Enabling Windows Defender Real time Scanning"
Set-MpPreference -DisableRealtimeMonitoring $false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment