Hi All, I am trying to get the above custom script to work and am having some problems. Hope you can help. I have configured the sensor to use the custom Get-DFSRBacklog.ps1 script but I am receiving:
XML: Structural error in xml file, 1 open items. -- JSON: The returned json does not match the expected structure (Invalid JSON.). (code: PE231)
I have saved the result to disk and am getting:
Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESS DENIED)) At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\Get-DFSRBa cklog.ps1:99 char:32 + $Namespaces = Get-WmiObject <<<< -class __Namespace -namespace root -com putername $computer | Where {$_.name -eq $namespace} + CategoryInfo : NotSpecified: (:) [Get-WmiObject], UnauthorizedA ccessException + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.Pow erShell.Commands.GetWmiObjectCommand C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\Get-DFSRBackl og.ps1 : MicrosoftDFS WMI Namespace does not exist on 'COMPUTERNAME'. Run locally on a system with the Namespace, or provide computer parameter of that system to ru n remotely. At line:1 char:2 + & <<<< 'C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\Get -DFSRBacklog.ps1' -computer COMPUTERNAME; exit $LASTEXITCODE + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorExcep tion + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio n,Get-DFSRBacklog.ps1
(nb I have replaced the real computername with COMPUTERNAME above)
Reading up I have found that passing credentials may not work running this script so I have entered credentials in manually to the script but still receive the same errors.
The script works if I run it from the computer the PRTG probe is installed on, it JUST doesn't work when executed by PRTG.
Any help greatly appreciated.
Article Comments
This is actually from a long time ago. I'm struggling to remember exactly what we did but we did get it working.
We did find it worked more reliably adding in a section just before "Function Check-WMINamespace:
$username="domain\user.name" $password="password" $secureString=convertto-securestring $password -AsPlainText -Force $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$secureString
Also one of the gotchya's we found was that PRTG uses x86 powershell. When testing we would automatically use x64 so the test was never a true test.
Make sure on the probe and server x86 powershell has the execution policies set to unrestricted.
Hope it helps.
Aug, 2015 - Permalink
Hi Matt
please check following
- Is the PRTG running with the same user credentials as when you logon to start the ps1?
- Are there any firewalls running on the local and remote machine?
- As Mike said, check if the same powershell version is used.
I had the same Problem, but I tried to check a DFS between 2 different domains (subdomain) and altough I was logged on as a domain/schema admin on the prtg server (member of domain.local) I got the WMI error. As soon as I used the domaincontroller (dc01.subdomain.domain.local) of the subdomain as sensordevice, it worked. Or when I executed the ps1 script on the DC of the subdomain it worked as well.
maybe that helps cheers Thomas
Aug, 2015 - Permalink
We have run into the exact same problem.
I have ensured both x64 and x86 powershell are 'unrestricted' on both probe and target machine.
PRTG probe service is running under LOCALSYSTEM account. Could this be my issue?
All firewalls are turned off. I seem able to query other WMI items on the remote server successfully - just not DFSR!
I can also run this script locally on the remote server and it works, so I know the script is good.
@ mike.orton - did you manage the fix the problem? if so, what was the cause?
Jan, 2016 - Permalink
Hello,
Please configure the EXE/Script Sensor's or EXE/Script Advanced Sensor's Security Context to Use security context of probe service and configure the PRTG Probe Service of the respective probe to run with an account which has sufficient access/privileges to perform the queries/actions required by the sensor instead of LOCALSYSTEM. Does the sensor work then?
Best Regards,
Jan, 2016 - Permalink
Hi Mike, We've been having the same issue for some time as well. We can manually run the PS1 file on the systems, and it reports back, typically, without issue. When running via PRTG or Kaseya script, it bombs-out with the aforementioned error.
If you manage to figure it out, please do tell. My coworker and I have some time scheduled over the coming weeks to hone-out a good solution for DFS/DFS-R monitoring - we're hopeful that the script will work...
Aug, 2015 - Permalink