I created a PowerShell script which checks the Windows Backup EventLogs for errors. The script is signed and it works when i run it manually from a different machine. For whatever reason, PRTG always returns the value 1, but it should return 3:Error (for testing). I have used the Invoke-Command cmdlet. I assume the script runs on the PRTG machine locally instead on the remote server. How can i debug this?

The other problem i'm facing is to replace the computer name with a variable %host, but this seems to be ignored by PRTG...

Invoke-Command -ComputerName servername{ $date=(Get-Date).AddDays(-100) $events=Get-WinEvent -LogName Microsoft-Windows-Backup| Where-Object {$_.TimeCreated -gt $date} | Group-Object -Property "LevelDisplayName" -NoElement IF ($events.Name -like "*Error*"){ $output = 3 Write-Host $output,":Error" IF ($events.Name -like "*Warning*"){ $output = 2 Write-Host $output,":Warning" } } ELSE { $output = 1 Write-Host $output,":OK" } }


Article Comments

You may want to take a look at monitoring historic Windows events :) It can also access remote hosts.


Jun, 2016 - Permalink

Thanks! I works at the meantime, i had to change the user of the PRTG services from local system to a domain user.


Jun, 2016 - Permalink

Nice that it works :)


Jun, 2016 - Permalink