VMware Cloud Community
RMichael
Contributor
Contributor
Jump to solution

A Newbie Question, Windows Activation Script

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.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

winact.png


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
RMichael
Contributor
Contributor
Jump to solution

How would I go about seeing what the current Activation status is?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

winact.png


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
RMichael
Contributor
Contributor
Jump to solution

Thank you very much. I appreciate your help.

0 Kudos