Hi Support,
I created a PowerShell script which works and returns the correct value when executed in PowerShell ISE on the PRTG server, however when executed in PRTG it returns value 0
I've tested with both the "security context" and " Windows credentials of parent device" options on the sensor, same output.
I've also tried to save output to log, but this does not contain any information about why this fails (as far as I can see anyway).
The script (identifiable values removed)
Import-Module UpdateServices $WSUSServer = Get-WsusServer -Name SERVERNAME.DOMAIN -PortNumber XXXX $LastReportTime = Get-WsusComputer -UpdateServer $WSUSServer -ComputerTargetGroups "Server" -IncludeSubgroups | Sort-Object -Property LastReportedStatusTime | Where-Object {$_.LastReportedStatusTime -lt (Get-Date).adddays(-14)} | select fulldomainname, LastReportedStatusTime $OverdueComputers = $LastReportTime.FullDomainname | Where-Object {$_.LastReportedStatusTime -lt (Get-Date).adddays(-14)} $OverdueComputersCount = $OverdueComputers.Count #Write result output Write-Host "<prtg>" Write-Host "<result>" "<channel>Overdue Servers</channel>" "<value>"+ $OverdueComputersCount +"</value>" "</result>" "<text>" + "" + $OverdueComputersCount + " servers are overdue to report in WSUS: " + $OverdueComputers + "</text>" Write-Host "</prtg>"
Any hints on how to get this script to return the correct values in PRTG is much appreciated.
Add comment