Featured image of post Monitoring with PowerShell Chapter 2: Monitoring Windows Activation State

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.

1
2

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:

1
2
3
4
5
6

$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.

All blogs are posted under AGPL3.0 unless stated otherwise
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy