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

active-directoryauditauthenticationlicensingwindows

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.

Best Answer

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