Hello, running the following script and receiving this error when trying to get information from remote servers. I can run the script myself and don't receive any errors, its only PRTG that is returning the error so I believe that it has something to do with the way PRTG is running the script. I have the correct credentials put in for the sensor, but other than that i'm not sure what could be the issue.
$hostname = "yourhostname" Invoke-Command -ComputerName $hostname{ $today=(Get-Date) $dateshift=(Get-Date).AddHours(-12) $EventError=Get-WinEvent -LogName Microsoft-Windows-Backup| Where-Object {$_.TimeCreated -gt $dateshift} | Where-Object {$_.LevelDisplayName -eq "Error"} $EventWarning=Get-WinEvent -LogName Microsoft-Windows-Backup| Where-Object {$_.TimeCreated -gt $dateshift} | Where-Object {$_.LevelDisplayName -eq "Warning"} $EventOK=Get-WinEvent -LogName Microsoft-Windows-Backup| Where-Object {$_.TimeCreated -gt $dateshift} | Where-Object {$_.LevelDisplayName -eq "Information"} $backupsets=Get-WBBackupSet $lastbackup=(Get-Date)-($backupsets.BackupTime |Measure-Object -Maximum |Select-Object -ExpandProperty Maximum) $lastbkround=[math]::Floor($lastbackup.TotalHours) $x = [string] $($EventError.Count)+":OK" Write-Host $x Exit 0 }
Add comment