I would like to have a script that will run against my VMs and in the case of Windows Servers identify if they are registered or not. I've been digging around but I may not be using the correct Google search questions or perhaps it can not be done. Has anyone here ever written or seen a script that does this? In the best case I'm hoping to set it up to run daily.
My problem is that someone on my server team is certain that VMs which were properly registered are becoming unregistered for some reason. I suspect they just were not registered properly in the beginning. I don't have empirical data to prove this but I think this script process will not only answer the question but it will also prevent this from being an issue in the future.
Thanks for reading this whether you have an answer or not.
You can do something like this
$computer = Get-Content Env:ComputerName
Get-WmiObject -Class SoftwareLicensingProduct -ComputerName $computer |
select name,licensestatus
One of the returned products should show a 1 in the licensestatus column
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This activates Windows.
You can run this inside the guest OS with the Invoke-VMScript cmdlet.
$computer = Get-Content Env:ComputerName
$wpaKey = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"
$wpa = Get-WmiObject -Query "Select * from SoftwareLicensingService" -ComputerName $computer
$wpa.InstallProductKey($wpaKey)
$wpa.RefreshLicenseStatus()
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
How would I go about seeing what the current Activation status is?
You can do something like this
$computer = Get-Content Env:ComputerName
Get-WmiObject -Class SoftwareLicensingProduct -ComputerName $computer |
select name,licensestatus
One of the returned products should show a 1 in the licensestatus column
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you very much. I appreciate your help.