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: , ,

6 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!

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

      But!
      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}}

Leave a Reply

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