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

7 comments on “Powershell: Listing activated clients on KMS server

  1. 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!!!

    1. 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}}

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

Leave a Reply

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