How Do I Get The Current License Server For A Large Number of Machines?
In Enterprise Deployments we generally work with a large number of machines (100+).
When we deprecate a license server we need the ability to identify machines which are out of conformance and need to be switched to a new license server. This is the first step towards creating a Scriptable Environment, testing current configuration. It is not efficient to log out to every single box and run LMU and we do not want the boxes to start encountering license errors.
How do we best address this issue?
Introducing Get-SynergyLicenseServer.ps1
There is an undocumented (and therefore subject to change) Registry Key (HKEY_LOCAL_MACHINE\SOFTWARE\Synergex\Synergy License Manager\ and HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Synergex\Synergy License Manager\) that can be READ (but not changed) to allow us to quickly identify what the machine is using as its license server.
Using the power of Remote Registry (https://msdn.microsoft.com/en-us/library/cc244877.aspx and https://docs.microsoft.com/en-us/dotnet/api/microsoft.win32.registrykey.openremotebasekey?redirectedfrom=MSDN&view=netframework-4.7.2) we can query a large number of machines very quickly.
The script/source are available here https://github.com/aolszowka/PowershellScripts/blob/master/Synergy/Get-SynergyLicenseServer.ps1 and are MIT Licensed which means you are free to use it in any commercial setting.
Usage
Get-SynergyLicenseServer
Will return the license server for the current machine like so:
ComputerName SynergyLicenseServer32 SynergyLicenseServer64 ------------ ---------------------- ---------------------- ACE_TEST synlm.example.com synlm.example.com
This also supports Pipeline Input (https://docs.microsoft.com/en-us/powershell/scripting/getting-started/fundamental/understanding-the-powershell-pipeline?view=powershell-6)
Therefore
"SERVER1", "SERVER2" | Get-SynergyLicenseServer
Will get the license servers for server1 and server 2 like so:
ComputerName SynergyLicenseServer32 SynergyLicenseServer64 ------------ ---------------------- ---------------------- SERVER1 synlm.example.com synlm.example.com SERVER2 synlm.example.com synlm.example.com
This is extremely powerful when combined with other cmdlets to investigate the network such as Get-ADComputer (https://docs.microsoft.com/en-us/powershell/module/addsadministration/get-adcomputer?view=win10-ps)
Get-ADComputer -Filter 'Name -like "build*"' | foreach { $_.DNSHostName } | Get-SynergyLicenseServer
Which will return all servers whose name are like "BUILD*", returning their DNSHostNames, piping it into Get-SynergyLicenseServer
ComputerName SynergyLicenseServer32 SynergyLicenseServer64 ------------ ---------------------- ---------------------- BUILD123 synlm.example.com synlm.example.com BUILD124 oldlm.example.com oldlm.example.com BUILD125 synlm.example.com synlm.example.com BUILD55 oldlm.example.com oldlm.example.com BUILD33 synlm.example.com synlm.example.com BUILD256 synlm.example.com synlm.example.com
You can then pipe this out even further to start filtering to identify bad license servers:
Get-ADComputer -Filter 'Name -like "build*"' | foreach { $_.DNSHostName } | Get-SynergyLicenseServer | Where-Object {$_.SynergyLicenseServer32 -eq "oldlm.example.com" -or $_.SynergyLicenseServer64 -eq "oldlm.example.com"}
Which will return (from the above example)
ComputerName SynergyLicenseServer32 SynergyLicenseServer64 ------------ ---------------------- ---------------------- BUILD124 oldlm.example.com oldlm.example.com BUILD55 oldlm.example.com oldlm.example.com
At which point you know which boxes need to be reconfigured.
The script is also smart about handling 32bit only OSes, scenarios where it cannot access remote registry, and situations where Synergy may not been installed at all.
ComputerName SynergyLicenseServer32 SynergyLicenseServer64 ------------ ---------------------- ---------------------- SERVER34 synlm.example.com Detected32bitOS SERVER35 AccessRemoteRegistryFailure AccessRemoteRegistryFailure SERVER36 NoValueOrNotInstalled synlm.example.com SERVER37 synlm.example.com
Do pay attention to the following:
- When Synergy becomes uninstalled it appears the uninstall leaves these keys in place, it is unclear if this is a bug or intended, this can produce unexpected results when querying large numbers of machines.
- This script is "single threaded" (I have not yet taken the time to perform PsJob conversion on this, I accept pull requests!) it can take a very long time to perform this over a large number of machines. Internally I performed this over ~800 machines and it took about 3 hours as many of these machines were bogus or I did not have the correct privilages.
For clarification on this post, it is intentional that the Synergy keys remain on the system after Synergy has been uninstalled.
Uninstalling License Manager