I’m building some virtual machines for my demo’s at the upcoming PowerShell summit. To make the demo’s, and setup, more interesting(?) I decided to use some Server Core instances.
The usual setup activities become a bit more interesting with Server Core – particular Windows activation.
Windows 2012 R2 will activate itself if the new machine has an Internet connection when it is created. With the GUI version of Windows you can check that Windows is activated using the System applet in Control Panel.
If you’re using Server Core you can use WMI to test activation:
Get-CimInstance -ClassName SoftwareLicensingProduct |
where PartialProductKey |
select Name, ApplicationId, LicenseStatus |
Use the SoftwareLicensingProduct WMI class and filter for PartialProductkey – that means a product key has been entered. You can then select the name of the product the ApplicationId and the LicenseStatus:
Name : Windows(R), ServerStandard edition
ApplicationId : 55c92734-d682-4d71-983e-d6ec3f16059f
LicenseStatus : 1
A License status of 1 indicates that its licensed – i.e. activated
More on using WMI to test and set activation in chapter 13 of PowerShell and WMI – www.manning.com/siddaway2