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 script not returning value

Votes:

0

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?

biztalk powershell wmi

Created on Apr 22, 2021 8:06:43 PM



4 Replies

Votes:

0

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.

Created on Apr 23, 2021 5:40:42 AM by  Florian Lesage [Paessler Support]



Votes:

0

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.

Created on Apr 23, 2021 12:26:38 PM

Last change on Apr 23, 2021 12:42:37 PM by  Felix Wiesneth [Paessler Support]



Votes:

0

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.

Created on Apr 23, 2021 12:36:02 PM



Votes:

0

Thank you very much for your feedback. I'm glad that it works now.

Have a nice day and weekend.

Regards.

Created on Apr 23, 2021 12:58:47 PM by  Florian Lesage [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.