⚡ PowerShell 5.1+

Watch Installed MSI Products for Changes

Polls Win32_Product on an interval and prints a line whenever the Installed MSI Products count changes — a lightweight way to notice new/removed items.

By WindowsScripting.com · 957 B
Watch-ProductChanges.ps1
<#
.SYNOPSIS
    Watches Installed MSI Products (Win32_Product) and reports when the item count changes.

.DESCRIPTION
    Polls Win32_Product every -IntervalSeconds and prints a line whenever the
    number of items returned changes since the last check. Press Ctrl+C
    to stop.

.PARAMETER IntervalSeconds
    How often to poll, in seconds. Defaults to 10.

.EXAMPLE
    .\Watch-ProductChanges.ps1 -IntervalSeconds 30
#>

[CmdletBinding()]
param(
    [int]$IntervalSeconds = 10
)

Write-Host "Watching Installed MSI Products every $IntervalSeconds second(s). Press Ctrl+C to stop." -ForegroundColor Cyan

$lastCount = -1
while ($true) {
    $count = (Get-CimInstance -ClassName Win32_Product).Count
    if ($count -ne $lastCount) {
        $timestamp = Get-Date -Format 'HH:mm:ss'
        Write-Host "[$timestamp] Installed MSI Products count: $count" -ForegroundColor Yellow
        $lastCount = $count
    }
    Start-Sleep -Seconds $IntervalSeconds
}