Learn how to upgrade your Windows edition with Powershell
If you are running on OEM licenses and finally getting a volume license or you need to change the Windows edition of your clients, you can do this with just a few Powershell commands.
All commands have to be executed on the client. Either use the Invoke-Command cmdlet or start a remote Powershell session. In this example we use a remote session:
Enter-PSSession -ComputerName yourclient
First of all, you can check which edition is active on the client:
Get-WindowsEdition -Online
The -online parameters let the cmdlet check for the active installation instead of an image.
The output looks like:
This client is running a professional edition of Windows.
To change the edition of Windows, you have to provide a new key for Windows. Either use your MAK key or one of the KMS client setup keys (if you want Windows to use your KMS).
These 2 commands will a) Connect to the software licensing service and b)change the key of the installed products to your product key:
$sls = Get-WmiObject -Query 'SELECT * FROM SoftwareLicensingService' @($sls).foreach({ $_.InstallProductKey('Windows-ProductKey') $_.RefreshLicenseStatus() })
If you are using a Key Management Server (KMS), you can use KMS Client setup key to tell your operating system that it should use the KMS to activate. The keys are:
- Windows 10 Enterprise: NPPR9-FWDCX-D2C8J-H872K-2YT43
- Windows 10 Enterprise N: DPH2V-TTNVB-4X9Q3-TJR4H-KHJW4
- Windows 10 Education: NW6C2-QMPVW-D7KKK-3GKT6-VCFB2
- Windows 10 Education N: 2WH4N-8QGBV-H22JP-CT43Q-MDWWJ
For a full list, check this Microsoft page.
To verify if the upgrade worked correctly, use the Get-WindowsEdition cmdlet again.
That’s all you need to do.
You can enhance the commands to upgrade many clients in batch processing or combine them to a script checking for the version and run only if required. Let me know in the comments what your script looks like.
Hi Andy,
Thank you so much for this post. I am working on upgrading all Win10 Pro machines in our company to Enterprise.
The script above:
$sls = Get-WmiObject -Query ‘SELECT * FROM SoftwareLicensingService’
@($sls).foreach({
$_.InstallProductKey(‘Windows-ProductKey’)
$_.RefreshLicenseStatus()
})
Runs when computers are online. It gives error when it can’t connect to a machine. How can I write the error output to a csv so I can see which machines are not successfully upgraded? I am learning Powershell as I go. Thank you for input.
If you put the command inside a Try Catch the Try portion will attempt to run, and the Catch will be what happens in the event of a failure, you can have it append the PC name to a file to get a list of systems that worked or didn’t work. Something like
@($sls).foreach({
TRY {
$_.InstallProductKey(‘Windows-ProductKey’)
$_.RefreshLicenseStatus()
}
CATCH {
Add-Content “PATH\TO\Log.txt” “$_,Failed”
})
Good stuff, worked a dream.
Had been putting off upgrading the 10 or so until I could work out how to do this remotely.
As usual someone smarter than me had already worked it out!
Also works fine as a remote session.
Thanks for posting this code. Why not also mention the generic KMS Client Key values which can be used in place of ‘Windows-ProductKey’ and can be found here: https://docs.microsoft.com/it-it/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/jj612867(v=ws.11)
Good idea. I’ve updated the post. Thanks for the comment!
Thank you, every one very valuable information.