Monitoring with PowerShell Chapter 2: Monitoring Windows Activation State

Hi All,
Today we will be focusing on monitoring the status of the Windows and office activation status, we use an imaging application to supply all of our machines with the correct version of Windows, but sometimes its forgotten to actually activate the OS. This script checks the current activation status and alerts on it.

Get-CimInstance -ClassName SoftwareLicensingProduct | Where-Object PartialProductKey | Select-Object Name, ApplicationId, LicenseStatus 

This very simple one-liner gives us the current OS and office installation activation status as a result, it is a little bit slow but alerting on this becomes quite easy:

$LicenseStatus = Get-CimInstance -ClassName SoftwareLicensingProduct | Where-Object PartialProductKey | Select-Object Name, ApplicationId, LicenseStatus
foreach($License in $LicenseStatus | where-object {$_.LicenseStatus -ne 1}) {
$LicenseError = "$($License.name) is not activated"
}
if(!$LicenseError){ $LicenseError = "Healthy"}

Sorry that the last 2 blogs are a bit on the short side! coming Monday I will resume with the longer blogs where we start remediating issues we’ve found in previous monitoring sets.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.