Updating KMS Server Address using PowerShell

When you deploy a new KMS server in order to replace your existing KMS server, you will need to update the “_VLMCS” DNS record. But you may want to manually force your clients to query the new KMS server. To perform this task, you can use slmgr.vbs in a PowerShell script.

First, get all the computers objects from Active Directory using the Get-ADComputer cmdlet.

Next, use slmgr.vbs with the “-skms” parameter followed by the new KMS server FQDN.

Finally, force the activation using the “-ato” parameter:

$ADComputers = Get-ADComputer -Filter 'ObjectClass -eq "Computer"' -SearchBase "OU=Servers,DC=GET-CMD,DC=local" | Select -Expand DNSHostName
 
foreach ($Comp in $ADComputers) {
 
slmgr.vbs $Comp -SKMS <FQDN_KMS_Server.get-cmd.local>
slmgr.vbs -ato
 
}

That’s all! All your clients has been updated!

 

Thanks for reading! You can follow me on Twitter @PrigentNico

About Nicolas 282 Articles
I work as an IT Production Manager, based in Paris (France) with a primary focus on Microsoft technologies. I have 10 years experience in administering Windows Servers. . I am a Microsoft MVP for Cloud & Datacenter Management. I also received the PowerShell Hero 2016 award by PowerShell.0rg. And finally, I am "MCSE: Cloud Platform and Infrastructure", "MCSA: Windows Servers", "Administering & Deploying SCCM", and CheckPoint CCSA certified.