Greetings!
I've created a powershell script to return a digit value:
$Process = get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter '(ServiceStatus = 32)' | measure-object write-host $process.count
This returns a number, usually a two digit number, but a number nonetheless. My Custom EXE sensor just reurns 0 as value. What's wrong?
Article Comments
Understood, and I made this change. I use this script:
invoke-command -file 'C:\Custom-Scripts\BizTalk - Get Dehydrated Instances.ps1' -computerName $serv
To call this script
$Process = get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter '(ServiceStatus = 32)' | measure-object $Value = $process.count write-host $Value":PRTG"
Which executes the script remotely. However, this does not return the numeric value I'm looking for.
Apr, 2021 - Permalink
Update: I realized that by daisy chaining scripts, I likely wasn't returning the value to the original caller. I have reformed the script as such:
$Result = Invoke-Command -ComputerName $serv -ScriptBlock { $Process = get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter '(ServiceStatus = 32)' | measure-object $Value = $process.count write-host $Value":PRTG" }
This returns my numeric value in the value:message format as requested by the API documentation. When I execute the script on the server, I get the desired response:
12:PRTG
Running the probe using the inherited Windows credentials helped as well. This is now working. Thank you for your time.
Apr, 2021 - Permalink
Thank you very much for your feedback. I'm glad that it works now.
Have a nice day and weekend.
Regards.
Apr, 2021 - Permalink
Hello,
Thank you for your message.
Are the information you are looking for available on the PRTG server or on the server where the probe is installed ? If not, then you have to execute the command remotely on the corresponding device.
I also invite you to use the option Use Windows credentials of parent device in the sensor settings, to execute the script with the Windows credentials defined in the parent device settings instead of the local system account (used by PRTG by default).
If you have questions, let us know.
Regards.
Apr, 2021 - Permalink