What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Getting Access Denied, PSSessionStateBroken error

Votes:

0

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
} 

exe powershell prtg-custom-sensor script windows-backup

Created on Aug 9, 2017 1:42:02 PM



4 Replies

Votes:

0

Hello,

Thank you very much for the KB-Post. Is the execution policy set to unrestricted (at least for testing)? Also, does it help to run the PRTG Probe Service under a domain admin account (instead of LOCAL SYSTEM)?

best regards.

Created on Aug 10, 2017 11:26:49 AM by  Torsten Lindner [Paessler Support]



Votes:

0

Thank you for replying, I changed the policy to unrestricted just to test and still get the same error. I can run the script just fine myself so I don't believe is has to do with that, and I am running the probe with domain admin credentials.

Created on Aug 10, 2017 7:22:29 PM



Votes:

0

Can you share a screenshot please, showing where the credentials are set for the Probe?

Created on Aug 11, 2017 7:15:02 AM by  Torsten Lindner [Paessler Support]



Votes:

0

It didn't dawn on me until last night that the credentials you were talking about and what I was referring to were different. After changing the actual probe service credentials to the domain admin, the script works as it is suppose to! Thank you!

Created on Aug 11, 2017 1:04:07 PM




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.