Activate Windows VMs using Powershell Direct

# This code requires Windows 10 professional/Enterprise or Windows Server 2016
$vmname = read-host "VMName"
$key = read-host "Windows Key"
 
Invoke-Command -VMName $vmname -ScriptBlock {
param($key)
Write-Verbose -Message "Attempting to inject Windows key: $key"
Cscript.exe $env:SystemRoot\System32\slmgr.vbs -ipk $key
Write-Verbose -Message "Attempting to activate Windows key"
Cscript.exe $env:SystemRoot\System32\slmgr.vbs -ato
} -ArgumentList $key

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.