In the past I’ve used the Microsoft Volume Activation Management Tool (VAMT) to apply licenses across an entire fleet of servers. there is, however, a bug in the tool which prevent you from using the letter ‘N’ in the license number. Even copy/paste doesn’t work – it simply drops any and all N’s.
Here’s what happens when I type the letter ‘N’:
So here’s a PoweShell script that levergaes WMI to install the license key, “invalid characters” and all.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# Load the Active Directory PowerShell module import-module activedirectory; # List an servers you want to exclude from this script (Cluster Objects etc) $excludedservers = "SQLCLUSTER1", "SQLCLUSTER2", "KAMALTEST"; # get all servers from AD $servers = get-adcomputer -filter {operatingsystem -like "*server*"} | sort name; # Loop through each server foreach ($server in $servers) { # Check if the current server is in the excluded list if ($excludedservers.contains($server.name)) { write-host "Excluding " $server.name; } else { # Check if server is online before using WMI if (test-connection -cn $server.name -count 1) { # Get Software Licensing Service information $sls = Get-WmiObject -query 'SELECT * FROM SoftwareLicensingService' -computername $server.name # Install license key and refresh $sls.InstallProductKey("ABCDE-FGHIJ-KLMNO-PQRST-UVWXY"); $sls.RefreshLicenseStatus(); } } } |