How to get Microsoft license authentication for all machines on a network?

Posted on

A server stack is the collection of software that forms the operational infrastructure on a given machine. In a computing context, a stack is an ordered pile. A server stack is one type of solution stack — an ordered selection of software that makes it possible to complete a particular task. Like in this post about How to get Microsoft license authentication for all machines on a network? was one problem in server stack that need for a solution. Below are some tips in manage your windows server when you find problem about windows, active-directory, authentication, licensing, audit.

We have a small network (~150 desktops, ~20 servers) much of which is Linux. MS keeps wanting to audit our MS products every 3 years or so. I really don’t have time to go around to 80-90 desktops and copy down the Win activation keys and then correlate the MS software licensing keys.

Is there some way I can get this information using Active Directory? Maybe using PowerShell?

Thanks in advance.

Generic solution:

I think the Microsoft-centric solution to this is to license using volume keys, and then simply use your KMS server to report on license activation status.

Windows 7 and above-solution

If volume licensing is not an option, and all of your clients are Windows 7 or newer, you could just query the SoftwareLicensingProduct WMI class on each machine to retrieve licensing details, here is an example using PowerShell and AD:

$Clients = Get-ADComputer -LDAPFilter "(&(operatingSystem=*Windows*))"

$LicenseQuery = "SELECT ApplicationID,Name,Description,ProductKeyID,PartialProductKey FROM SoftwareLicensingProduct WHERE LicenseStatus = 1"

foreach($Client in $Clients){
    $ActiveLicenses = @(Get-WmiObject -Query $LicenseQuery -ComputerName $Client.Name)
    if($ActiveLicense.Count -le 1){
        Write-Warning "Unable to find active license for computer $($Client.Name)"
    # Do what you want with the license information here

It will require a bit of error handling and output logic (you could export the details to a CSV file if you want), but this whould get you going in the right direction.

The attributes I’ve included in the query should be sufficient for an audit, but ask Microsoft if in doubt

We deployed OCS Inventory. Its free, awesome and provides all the info that you’d need.

OCS Inventory NG Projet

using NirSoft ProduKey:

ProduKey.exe /remoteall 

look for other command line options are in readme.txt

The way we handle it is our PowerShell startup scripts use NirSoft ProduKey to pull that information from the system, and upload the data to a file share. We were already using PowerShell startup scripts to manage a lot of our administrative tasks, so it was easy enough to add another step.

Whenever I get questioned on licenses, I just grep the uploaded reports and make sure the counts match, check for duplicate keys, etc.

At first, I had my PowerShell script crawl WMI and the registry manually for this info, but there were a couple of edge cases that NirSoft’s tool handled better than my home-grown thing.

Leave a Reply

Your email address will not be published.