I tried to create a simple PowerShell script to monitor my Hyper-V cluster. The script works if I run it manually on the PRTG server but for some reason the sensor status is always Up. What could be the problem?
$Nodes = Get-ClusterNode -Cluster HVCluster01 $Interfaces = Get-ClusterNetworkInterface -Cluster HVCluster01 $NodeStatus = $null $InterfaceStatus = $null ForEach ($Node in $Nodes) { $NodeState = $Node.State If ($NodeState -ne "Up") { $NodeStatus = "Down" } Else {} } ForEach ($Interface in $Interfaces) { $InterfaceState = $Interface.State If ($InterfaceState -ne "Up") { $InterfaceStatus = "Down" } Else {} } If ($NodeStatus -eq "Down" -or $InterfaceStatus -eq "Down") { Write-Host "Status:Down" exit 2 } Else { Write-Host "Status:Ok" exit 0 } }
Add comment