Determine installed Windows version:
 
DISM /online /Get-CurrentEdition
Check possible target editions:
 
DISM /online /Get-TargetEditions
Activate Windows using an existing license
 
$key = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"
$licensingService = get-wmiObject -query "select * from SoftwareLicensingService" -computername $env:computername
$licensingService.InstallProductKey($key)
$licensingService.RefreshLicenseStatus()
Activate Windows using an existing license on a list of remote Windows machines:
 
$remoteWindows="SHERVER01","SHERVER02"
$licenseKey="H3RNG-8C32Q-Q8FRX-6TDXV-WMBMW" #AVMA default DataCenter serial

function activateWindows{
param(
[string]$key = "H3RNG-8C32Q-Q8FRX-6TDXV-WMBMW"
)
$licensingService = get-wmiObject -query "select * from SoftwareLicensingService" -computername $env:computername;
$licensingService.InstallProductKey($key);
sleep 20;
$licensingService.RefreshLicenseStatus();
}

Invoke-Command -computer $remoteWindows -ScriptBlock{
param($importedFunc,$importedKey)
[ScriptBlock]::Create($importedFunc).Invoke($importedKey);
} -Args ${function:activateWindows},$licenseKey

#Validate licensing status
Get-CimInstance -computername $remoteWindows -ClassName SoftwareLicensingProduct|where {$_.PartialProductKey}|select Description, LicenseStatus

<# Sample Output
Description LicenseStatus
----------- -------------
Windows(R) Operating System, VOLUME_MAK channel 1
Windows(R) Operating System, VOLUME_MAK channel 1
Windows(R) Operating System, VOLUME_MAK channel 1
Windows(R) Operating System, VOLUME_MAK channel 1
Windows(R) Operating System, VOLUME_MAK channel 1
Windows(R) Operating System, VOLUME_MAK channel 1
Windows(R) Operating System, VOLUME_MAK channel 1
Windows(R) Operating System, VOLUME_MAK channel 1
#>
Initiate Windows Upgrade:
 
$licenseKey="XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"
DISM /online /Set-Edition:ServerDatacenter /ProductKey:$licenseKey /AcceptEula
The other license for 2 cpus:
 
DISM /online /Set-Edition:ServerDatacenter /ProductKey:$licenseKey /AcceptEula
If this machine is to be cloned, one must run SysPrep prior to saving its image!
 
Convert Windows Evaluation Edition to Standard Edition:
 
DISM /online /Set-Edition:ServerStandard /ProductKey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX /AcceptEula

Automatic Virtual Machine Activation (AVMA) can be used to activate VMs in Hyper-V (only). This method requires a Microsoft Virtualization Host running Windows Server 2019 Datacenter, Windows Server 2016 Datacenter, or Windows Server 2012 R2. (source:

AVMA keys

The following AVMA keys can be used for Windows Server 2019.

Edition AVMA key
Datacenter H3RNG-8C32Q-Q8FRX-6TDXV-WMBMW
Standard TNK62-RXVTB-4P47B-2D623-4GF74
Essentials 2CTP7-NHT64-BP62M-FV6GG-HFV28

The following AVMA keys can be used for Windows Server, version 1809.

Edition AVMA key
Datacenter H3RNG-8C32Q-Q8FRX-6TDXV-WMBMW
Standard TNK62-RXVTB-4P47B-2D623-4GF74

The following AVMA keys can be used for Windows Server, version 1803 and 1709.

Edition AVMA key
Datacenter TMJ3Y-NTRTM-FJYXT-T22BY-CWG3J
Standard C3RCX-M6NRP-6CXC9-TW2F2-4RHYD

The following AVMA keys can be used for Windows Server 2016.

Edition AVMA key
Datacenter TMJ3Y-NTRTM-FJYXT-T22BY-CWG3J
Standard C3RCX-M6NRP-6CXC9-TW2F2-4RHYD
Essentials B4YNW-62DX9-W8V6M-82649-MHBKQ

The following AVMA keys can be used for Windows Server 2012 R2.

Edition AVMA key
Datacenter Y4TGP-NPTV9-HTC2H-7MGQ3-DV4TW
Standard DBGBW-NPF86-BJVTX-K3WKJ-MTB6V
Essentials K2XGM-NMBT3-2R6Q8-WF2FK-P36R2

How to apply AVMA: pick the correct key using the chart above, then run this command

$avmaKey="H3RNG-8C32Q-Q8FRX-6TDXV-WMBMW"
slmgr /ipk $avmaKey
keywords: cd key, serial, keygen