Get OS License Details using PowerShell
In this post, I will show you how to get OS license details using PowerShell. This script helps you find the operating system license information such as Windows product key, license status, license URL and much more.
OS licenses are contracts that grant users the right to access and use the software. Administrators must make sure that these licenses are used in accordance with the organization’s policies. This includes making sure that the right number of licenses are being used and that the licenses are legitimate and not infringed.
When you have multiple computers in your setup, it takes time to manually check each device’s license information. Hence, a handy PowerShell script is what you need to get the license details on operating system.
In one of my blog posts, I covered onmultiple ways to activate Windows 11. PowerShell can be used to find out most of the details about the OS, including the license information. You can run different PowerShell commands to find out about the OS license. For example, you can run the following PowerShell command to get the product key for Windows 11 “(Get-WmiObject -query ‘select * from SoftwareLicensingService’).OA3xOriginalProductKey“.
Before you read further, check out some really useful PowerShell guides.
- How to Uninstall Windows Updates using PowerShell
- List all Azure Regions using PowerShell | Azure Cloud Shell
- List of Useful TPM PowerShell CmdLets
- How to Unlock User Accounts with PowerShell
Get OS License Details using PowerShell
We’ll now go through the steps to get OS license details using PowerShell that will retrieve important license details of the operating system. The following script will fetch license details like license name, Description, Application ID, Product Key Channel, License URL, Validation URL, Partial Product Key, Product Key ID, License Status, and Product Key. You can download this script from myGitHub repository.
Copy the below PowerShell script to a notepad or text editor and save it asGetOSlicensedetails.ps1.
$lic = Get-WmiObject -Class SoftwareLicensingProduct | Where-Object {$_.PartialProductKey -ne $null} $id = (Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey echo "License Name: $($lic.Name)" echo "Descriptions: $($lic.Description)" echo "Application ID: $($lic.ApplicationId)" echo "Product Key Channel: $($lic.ProductKeyChannel)" echo "Use License URL: $($lic.UseLicenseURL)" echo "Validation URL: $($lic.ValidationURL)" echo "PartialProductKey: $($lic.PartialProductKey)" echo "ProductKey ID: $($lic.ProductKeyID)" echo "License Status: $($lic.LicenseStatus)" echo "Product Key: $id"
To run the above PowerShell script, launch the PowerShell as administrator. To accomplish this, click Start and type ‘PowerShell在搜索框。从list of results, select PowerShell and choose the optionRun as administrator.
In the PowerShell window, run thegetosdetails.ps1. The PowerShell output now displays the following OS license information.
- License name
- Descriptions
- Application ID
- Product Key Channel
- License URL
- Validation URL
- 部分产品密钥
- Product Key ID
- License Status
- Product Key