⚡ PowerShell 5.1+
Watch Network Adapter Configuration for Changes
Polls Win32_NetworkAdapterConfiguration on an interval and prints a line whenever the Network Adapter Configuration count changes — a lightweight way to notice new/removed items.
Watch-NetworkAdapterConfigChanges.ps1
<#
.SYNOPSIS
Watches Network Adapter Configuration (Win32_NetworkAdapterConfiguration) and reports when the item count changes.
.DESCRIPTION
Polls Win32_NetworkAdapterConfiguration 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-NetworkAdapterConfigChanges.ps1 -IntervalSeconds 30
#>
[CmdletBinding()]
param(
[int]$IntervalSeconds = 10
)
Write-Host "Watching Network Adapter Configuration every $IntervalSeconds second(s). Press Ctrl+C to stop." -ForegroundColor Cyan
$lastCount = -1
while ($true) {
$count = (Get-CimInstance -ClassName Win32_NetworkAdapterConfiguration).Count
if ($count -ne $lastCount) {
$timestamp = Get-Date -Format 'HH:mm:ss'
Write-Host "[$timestamp] Network Adapter Configuration count: $count" -ForegroundColor Yellow
$lastCount = $count
}
Start-Sleep -Seconds $IntervalSeconds
}