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 Smilie: :)
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).

Category(s): Microsoft, Powershell
Tags: , ,

12 Responses to Powershell: Listing activated clients on KMS server

  1. Hi, there is a typo (Get-Eventlog).

    $(foreach ($entry in (Get-EventLog -Logname “Key Management Service”Smilie: ;)) {$entry.ReplacementStr
    ings[3]}) | sort-object -Unique

    This was a great script to get all servers. Smilie: :-) Thanks!!!

  2. Thanks a lot!

    Shiva Kumar says:

    Can we also get the Operating system name of the licensed client?

    • 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.

      This is powershell Smilie: :)
      You can couple the line with get-adcomputer to pull operating system name from AD:
      $(foreach ($entry in (Get-EventLog -Logname “Key Management Service”Smilie: ;)) {$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. Smilie: :(

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

  4. Thanks a lot, script work for me.

  5. 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(‘.’Smilie: ;)[0] -Properties OperatingSystem).OperatingSystem}}

    Pierre Wong says:

    Very useful, thanks.

2 Responses in other blogs/articles

Leave a Reply

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


This site uses Akismet to reduce spam. Learn how your comment data is processed.