Contents
In this blog post, we will learn to retrieve Windows 10/11 OS license details using PowerShell scripts. There are other ways to find out Windows OS license information as well. However, using a PowerShell script is much quicker and provides you with the results directly on the console.
Activating Windows OS using a legitimate product key unlocks Windows features so you can utilize the full functionality of the OS. In this post, we will see PowerShell scripts that can get below Information about the OS from your device:
- License Name: Windows Operating system edition details
- Description: More Information about Windows edition installed on the device
- Application ID
- Product Key Channel
- License URL
- Validation URL
- Partial Product Key
- Product Key ID
- License Status
- Product Key: OEM Product key
Retrieve Windows OS License Details using PowerShell: Script 1
I have created and tested below PowerShell script, which will help you find all the information we discussed above about the OS license details of Windows 10/11.
I have also provided steps for running this PowerShell script and the output you can expect. You can also download this script from my GitHub repository. Copy below code and paste it into a notepad and save the file as Get-OSlicensedetails.ps1
.
Get-OSlicensedetails.ps1
<# .DESCRIPTION This script will get Windows OS details like license name, Product key information etc. Author: Jatin Makhija Website: Copyright - Cloudinfra.net Version: 1.0.0 #> # Define color codes for better formatting $foregroundColor = "Green" $backgroundColor = "Black" # Retrieve OS License Information # Get the license object with a valid partial product key $license = Get-WmiObject -Class SoftwareLicensingProduct | Where-Object { $_.PartialProductKey -ne $null } # Get the original product key from SoftwareLicensingService $productKey = (Get-WmiObject -Query 'select * from SoftwareLicensingService').OA3xOriginalProductKey # Display License Details Write-Host "Operating System License Details:" -ForegroundColor $foregroundColor -BackgroundColor $backgroundColor Write-Host "---------------------------------" -ForegroundColor $foregroundColor -BackgroundColor $backgroundColor Write-Host "License Name: $($license.Name)" -ForegroundColor $foregroundColor Write-Host "Description: $($license.Description)" -ForegroundColor $foregroundColor Write-Host "Application ID: $($license.ApplicationId)" -ForegroundColor $foregroundColor Write-Host "Product Key Channel: $($license.ProductKeyChannel)" -ForegroundColor $foregroundColor Write-Host "Use License URL: $($license.UseLicenseURL)" -ForegroundColor $foregroundColor Write-Host "Validation URL: $($license.ValidationURL)" -ForegroundColor $foregroundColor Write-Host "Partial Product Key: $($license.PartialProductKey)" -ForegroundColor $foregroundColor Write-Host "Product Key ID: $($license.ProductKeyID)" -ForegroundColor $foregroundColor Write-Host "License Status: $($license.LicenseStatus)" -ForegroundColor $foregroundColor Write-Host "Product Key: $productKey" -ForegroundColor $foregroundColor -BackgroundColor $backgroundColor
Once you have the PowerShell script file Get-OSlicensedetails.ps1
ready. Execute the script using by using below steps:
- Open PowerShell console as administrator.
- Navigate to the folder where the PowerShell script is stored. Execute the PowerShell script by typing
.\Get-OSlicensedetails.ps1
Retrieve Windows OS License Details using PowerShell: Script 2
If you prefer to work with PowerShell functions, below script contains a PowerShell function to get Windows 10/11 operating system details. The output of the script will remain the same as we saw above.
- Copy below code and paste it into a notepad and save the file as
Get-OSlicensedetails.ps1
- Open PowerShell console as administrator.
- Navigate to the folder where the PowerShell script is stored. Execute the PowerShell script by typing
.\Get-OSlicensedetails.ps1
.
Get-OSlicensedetails.ps1
<# .DESCRIPTION This script will get Windows OS details like license name, Product key information etc. Author: Jatin Makhija Website: Copyright - Cloudinfra.net Version: 1.0.0 #> # Define color codes for better formatting $foregroundColor = "Green" $backgroundColor = "Black" # Function to retrieve license information Function Get-OSLicenseInfo { $license = Get-WmiObject -Class SoftwareLicensingProduct | Where-Object { $_.PartialProductKey -ne $null } $productKey = (Get-WmiObject -Query 'select * from SoftwareLicensingService').OA3xOriginalProductKey return $license, $productKey } # Display license details function Show-LicenseInfo { param( $license, $productKey ) Write-Host "Operating System License Details:" -ForegroundColor $foregroundColor -BackgroundColor $backgroundColor Write-Host "---------------------------------" -ForegroundColor $foregroundColor -BackgroundColor $backgroundColor Write-Host "License Name: $($license.Name)" -ForegroundColor $foregroundColor Write-Host "Description: $($license.Description)" -ForegroundColor $foregroundColor Write-Host "Application ID: $($license.ApplicationId)" -ForegroundColor $foregroundColor Write-Host "Product Key Channel: $($license.ProductKeyChannel)" -ForegroundColor $foregroundColor Write-Host "Use License URL: $($license.UseLicenseURL)" -ForegroundColor $foregroundColor Write-Host "Validation URL: $($license.ValidationURL)" -ForegroundColor $foregroundColor Write-Host "Partial Product Key: $($license.PartialProductKey)" -ForegroundColor $foregroundColor Write-Host "Product Key ID: $($license.ProductKeyID)" -ForegroundColor $foregroundColor Write-Host "License Status: $($license.LicenseStatus)" -ForegroundColor $foregroundColor Write-Host "Product Key: $productKey" -ForegroundColor $foregroundColor -BackgroundColor $backgroundColor } # Retrieve license information $license, $productKey = Get-OSLicenseInfo Show-LicenseInfo -license $license -productKey $productKey