Table of Contents
This blog post will discuss finding license information for your Windows 10/11 operating system using Powershell. 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.
In a recent blog post, I discussed 4 ways to get Windows 10/11 product key information. The Windows product key is a code you may have used to activate your Windows 10/11 Operating system.
Activating Windows OS using a legitimate product key unlocks Windows features so you can utilize the full functionality of the OS. Today, we will explore Powershell scripts that can fetch 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
Before we proceed further, Check-out some of the useful Powershell guides below:
Retrieve Windows OS License details using Powershell – Script 1
I have created and tested the PowerShell script below, which will help you find all the information we discussed above about the OS license details of Windows 10/11.
I have provided detailed 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. You can follow the below steps to execute it.
- Search for Powershell in the Start Menu.
- On Powershell Icon, right-click on it and click on Run 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, the script below contains a Powershell function to fetch 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
- Search for Powershell in the Start Menu.
- On Powershell Icon, right-click on it and click on Run 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