Last active
July 21, 2022 13:25
-
-
Save gdyr/86533963b6fe14ed9c57eb7ae0adba29 to your computer and use it in GitHub Desktop.
Monitor Cisco switch IGMP groups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-CiscoIGMPGroups { | |
return plink -ssh cisco@10.10.10.17 -pw cisco -batch "sh ip igmp snooping groups | include 224.0.1.129" 2>$null | ? {$_.Length -gt 0}; | |
} | |
Write-Output "Starting IGMP group monitoring." | |
Write-Output "Press any key to exit..." | |
Write-Output ""; | |
$prevEntry = ""; | |
do { | |
$entry = Get-CiscoIGMPGroups; | |
if($entry -ne $prevEntry) { | |
Write-Output "IGMP Group membership changed:" | |
Write-Output $((Get-Date).ToString().Trim()); | |
if($entry.Length -gt 0) { | |
Write-Output $entry; | |
} else { | |
Write-Output "(group empty)"; | |
} | |
} | |
$prevEntry = $entry; | |
Start-Sleep -Seconds 2; | |
} until ([System.Console]::KeyAvailable); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
.\igmplog.ps1 | Tee-Object -FilePath IGMPLog.txt