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

Powershell - File Acces on other domain is "access denied"

Votes:

0

Hello,

I am currently trying to monitor a file via a powershell script in other domain. It's a forrest where all domains are trusted.

The Probe is located in domain A which can execute the script and can fetch the file on servers in domain A. When I am trying to execute this script for a server which is located in domain B, the script cannot get the item and says "access denied".

Basically the Probe in domain A needs to monitor a file in Domain B via powershell.

#### Script #### param([string]$path)

$file = Get-Item -Path $path

if(!(Test-Path $path)) {

New-Item -Path $path exit 0 } else{

if ($file.LastWriteTime -le ((Get-Date).AddHours(-1)) ) { Write-Host "2:File Age is older than 60 minutes (file age: $file.LastWriteTime)" exit 2 } }

write-host "0:ok"

#### End ####

We currently are right in the middle of a domain migration, therefore I cannot create a probe for every domain just to run the script and monitor only one file/one server.

The credential for each domain are different, but the correct ones are configured in the credentials area in PRTG. Is it possible to tell PRTG to use specific credentials for the execution of a powershell script?

Is there any "easier" way to monitor file with the following functions?

- Check if the file exists, if no then create the file and go ok

- Check the file age, if it's older than 60 minutes go critical otherwise say ok

file file-monitoring powershell

Created on Mar 2, 2020 10:04:00 AM



1 Reply

Votes:

0

Dear Nyu,

you can change the security context for the custom script sensor on the "Settings" tab of that sensor. Please select the Windows credentials from the parent device. In said device, please make sure to enter the correct credentials, this is done on the respective "Settings" tab as well.

Created on Mar 2, 2020 4:16:58 PM by  Arne Seifert [Paessler Support]




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.