The following script is working on the PRTG server in a power shell without problems but from PRTG (custom sensor) not. Please assist. Thank you.
-------------------------------------- [string]$status = "" [string]$result = "" if ($args.count -eq 2) { [string]$server = $args[0] [string]$queue = $args[1] if ($server.Contains(".")) { #remove domain part from name [string]$queueName = $server.Substring(0, $server.IndexOf(".")) + "\" + $queue } } else { $status = "Missing parameters Server Queue" } if ($status -eq "") { Try { $objItem = Get-Queue -server $server | Where-object {$_.Identity -eq $queueName} | Select-object MessageCount if ($objItem -is [Object]) { $result = $objItem.MessageCount.ToString() $result = $result.Trim() } else { $status = "No results for Server=" + $server + ", Queue=" + $queue } } Catch { $status = "Executing Get-Queue Server=" + $server + ", Queue=" + $queueName } } if ($status.Length -eq 0) { write-host $result, ":OK" exit 0 } else { $status = "0:ERROR " + $status write-host $status exit 1 }
Add comment