Powershell: Listing activated clients on KMS server

Powershell: Listing activated clients on KMS server

If you are using a KMS server for activating servers and clients in your environment, you may have noticed that there’s really no obvious way to get a list of all the clients that have been activated by the KMS server.
One way to get that overview is by using VAMT (http://technet.microsoft.com/en-us/library/hh824953.aspx), but since that tool is based on pulling info from clients and not from the KMS server it is not suitable for everyone.
Thankfully, there’s PowerShell 🙂
Getting a list of all activated KMS clients through PowerShell is actually a simple one-liner:

$(foreach ($entry in (Get-EventLog -Logname "Key Management Service")) {$entry.ReplacementStrings[3]}) | sort-object -Unique

What this does is look through the Key Management Service eventlog, grab only the client name and then remove all duplicates (since a client activates itself at regular intervals, there will be duplicates).

11 comments

Hi, there is a typo (Get-Eventlog).
$(foreach ($entry in (Get-EventLog -Logname “Key Management Service”)) {$entry.ReplacementStr
ings[3]}) | sort-object -Unique
This was a great script to get all servers. 🙂 Thanks!!!

Operating system name is not stored in the eventlog so initially the answer would be no, you can’t get operating system name as well.
But!
This is powershell 🙂
You can couple the line with get-adcomputer to pull operating system name from AD:
$(foreach ($entry in (Get-EventLog -Logname “Key Management Service”)) {$entry.ReplacementStrings[3]}) | sort-object -Unique | Select-Object @{Name=”clientName”;Expression={$_}},@{Name=”Operating System Name”;Expression={(Get-ADComputer $_ -Properties OperatingSystem).OperatingSystem}}

Hi Nerenther,
Thanks for clearing my doubt, but unfortunately my KMS server is placed DMZ zone and it is in workgroup. 🙁

Hi there. This is sweet. Anyone know how to list off what PC’s have a KMS activated version of Visio 2010?
Great work!

Hi Nerenther,
Thank you for writing this script. I had to make a slight modification to get the script to work since in my situation, the clientname contained a FQDN, Get-ADComputer would fail to return any results.
Here is my modification, that I would like to share.
$(foreach ($entry in (Get-EventLog -Logname “Key Management Service”)) {$entry.ReplacementStrings[3]}) | sort-object -Unique | Select-Object @{Name=”clientName”;Expression={$_}},@{Name=”Operating System Name”;Expression={(Get-ADComputer $_.Split(‘.’)[0] -Properties OperatingSystem).OperatingSystem}}

Leave a Reply

Your email address will not be published. Required fields are marked *