Troubleshooting Windows activation failures on Azure VMs

If you are experiencing Windows activation failures on an Azure VM, please try the following steps to resolve the issue. An example of an error message you may see is:

Error(s): Activating Windows(R), ServerDatacenter edition
Error: 0xC004F074 The Software Licensing Service reported that the computer could not be activated. No Key Management Service (KMS) could be contacted. Please see the Application Event Log for additional information.
 

  1. Download and extract the Psping tool to a local folder in the VM that is failing to activate.

    https://technet.microsoft.com/en-us/sysinternals/jj729731.aspx

    To download the file, first go to Server Manager, Configure this local server, select IE Enhanced Security Configuration, and selecting Off under Administrators.
     

  2. Go to Start, search on Windows PowerShell, right-click Windows PowerShell and select Run as administrator.
       

  3. Make sure the VM is configured to use the Azure KMS server by running the following command. This is set at VM creation, so running this command is just a troubleshooting step to make sure the proper configuration is set.

    iex "$env:windir\system32\cscript.exe $env:windir\system32\slmgr.vbs /skms kms.core.windows.net:1688"

    The command should return:

    Key Management Service machine name set to kms.core.windows.net:1688 successfully.
       

  4. Verify with Psping that you have connectivity to the KMS server. Switch into the folder where you extracted the Pstools.zip download, then run:

    .\psping.exe kms.core.windows.net:1688

    In the second-to-last line of the output, make sure you see:

    Sent = 4, Received = 4, Lost = 0 (0% loss)

    If Lost is greater than 0, the VM does not have connectivity to the KMS server. In that case, if the VM is in a virtual network and has a custom DNS server specified, you must make sure that DNS server is able to resolve kms.core.windows.net. Or, change the DNS server to one that does resolve kms.core.windows.net. Note that if you remove all DNS servers from a virtual network, VMs will then use Azure's internal DNS service, which is able to resolve kms.core.windows.net.

    Aside from DNS issues, verify the guest firewall has not been configured in such a way that would block activation attempts.
     

  5. After verifying successful connectivity to kms.core.windows.net, run the following command from that elevated PowerShell prompt. This command attempts activation multiple times in a row.

    1..12 | % { iex "$env:windir\system32\cscript.exe $env:windir\system32\slmgr.vbs /ato" ; start-sleep 5 }

    Successful activation will return:

    Activating Windows(R), ServerDatacenter edition (12345678-1234-1234-1234-12345678) ...
    Product activated successfully.
     

  6. If activation still failed, and the VM is running Windows Server 2012 R2 Datacenter, Standard, or Essentials, try the command below for the specific SKU. You can verify the OS version by going to Start, searching on Msinfo32, double-clicking Msinfo32.exe, and looking at the OS Name in the right pane.

    For Windows Server 2012 R2 Datacenter, run the following from the elevated PowerShell prompt:

    iex "$env:windir\system32\cscript.exe $env:windir\system32\slmgr.vbs /ipk Y4TGP-NPTV9-HTC2H-7MGQ3-DV4TW"

    For Windows Server 2012 R2 Standard, run the following from the elevated PowerShell prompt:

    iex "$env:windir\system32\cscript.exe $env:windir\system32\slmgr.vbs /ipk DBGBW-NPF86-BJVTX-K3WKJ-MTB6V"

    For Windows Server 2012 R2 Essentials, run the following from the elevated PowerShell prompt:

    iex "$env:windir\system32\cscript.exe $env:windir\system32\slmgr.vbs /ipk K2XGM-NMBT3-2R6Q8-WF2FK-P36R2"

    After entering the specific command above for the SKU of Windows Server 2012 R2 the VM is using, try activating again:

    iex "$env:windir\system32\cscript.exe $env:windir\system32\slmgr.vbs /ato"
     

  7. At this point if you are still unable to activate the VM, check the Application event log for events from source Microsoft-Windows-Security-SPP to help understand why activation is failing.