PowerShell script to check windows activation status on multiple servers (2021)

PowerShell script to check windows activation status on multiple servers
PowerShell script to check windows activation status

Coming straight to our topic today the Powershell script to check the windows activation status on multiple servers we will discuss step by step how I have created a small yet interesting script to fetch the details in a CSV format. Let’s head back to windows license status and what it means before we understand the script.

Share on facebook
Share on twitter
Share on linkedin
PowerShell script to check windows activation status on multiple servers

Types of WIndows license status

We all know that there are 2 statuses either it will be active or not licensed but let me tell you there are more than we can imagine. Let me walk through each of them.

 

  1. Status Unknown – Shows all goods for which the VAMT has not or is unable to collect licensing status. Any PCs that have been added but whose installed products have not yet been detected are included in this category.
  2.  
  3. Licensed – Shows only products that have been activated with a valid product key.
  4.  
  5. Out-of-the-Box (OOB) Display all products that are still within the initial grace period permitted by Windows, Windows Server, or Microsoft Office 2010 prior to required activation.
  6.  
  7. Non-Genuine Grace – Applicable only to systems running Windows Vista RTM edition.  This indicates the system has failed online genuine validation and is in 30 day grace period.
  8.  
  9. Out of Tolerance (OOT) Grace – Display all products that have had hardware or BIOS changes significant enough to require reactivation, and all KMS client products that have not renewed their activation within the 180 days activation renewal period.
  10.  
  11. Unlicensed – The status of activation cannot be determined. It could indicate that activation-related binaries and configuration values have been tampered with. This only applies to Windows Vista RTM or retail editions of Office 2010.
  12.  
  13. Notification – Display all products that have passed the activation grace period or have failed validation. These products will be subjected to a notification experience but will continue to function normally.
  14.  
  15. Extended Grace – When we extend the grace period manually. Generally a windows server license expires in 180 days.

Powershell script to check Windows license status

Step #1

Param is generally used when we require static parameters. To learn more click here.

Also to learn more about the Paramater attribute ValueFromPipelineByPropertyName click here.

				
					Param
(
    [Parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)]
    [String[]]$ComputerName = $env:COMPUTERNAME
)
				
			

Step #2

Providing the license status as an array to $LicenseStatus.

				
					
#defined initial data
$LicenseStatus = @("Unlicensed","Activated","OOB Grace",
"OOT Grace","Non-Genuine Grace","Notification","Extended Grace")
				
			

Step #3 

Providing the list of the servers for which the data is required.

If you are not familiar with how the foreach loop works I strongly suggest you click on the below link.

https://powershellguru.com/foreach-and-foreach-object/

				
					$computerName= GC -path "C:\users\test\desktop\servers.txt"
Foreach($CN in $ComputerName)
				
			

Step #4

The Get-CimInstance cmdlet retrieves CIM instances from a CIM server. For this cmdlet, you can specify either the class name or a query.

SoftwareLicensingProduct : This class exposes the Software Licensing service’s product-specific properties and methods. Read more here.

				
					{
    Get-CimInstance -ClassName SoftwareLicensingProduct -ComputerName $CN |`
    Where{$_.PartialProductKey -and $_.Name -like "*Windows*"} | select `
    @{Expression={$_.PSComputerName};Name="ComputerName"},
    @{Expression={$LicenseStatus[$($_.LicenseStatus)]};Name="LicenseStatus"} | export-csv "C:\Users\test\Desktop\result.csv" -Append
}  
				
			

Conclusion

I hope you have liked this post (PowerShell script to check windows activation status) and will implement this whenever it is required to get the details of windows license status from multiple remote servers. Things you should always remember is to use only 1 server for testing purposes and the rest you can try to install if everything is working fine. Let me know if you want a blog post on some other script that might amaze you.

We are working continuously to provide you with the better and the best scripts daily. We will publish weekly hence don’t forget to subscribe to our newsletter. 

Advertisement. Scroll to continue reading.
close
blank

DON’T MISS A POST

Keep up to date with PowershellGuru

SSShhhhhhh.........We don’t spam!

Powershell Blogs
PowerShell script to check windows activation status on multiple servers
Share via
Copy link