NetXMS Support Forum

English Support => General Support => Topic started by: Anders on August 02, 2012, 10:06:53 AM

Title: Query PowerShell via Agent
Post by: Anders on August 02, 2012, 10:06:53 AM
Hi,

I wonder if it would be possible to execute a PowerShell command via the agent and return the output result to NetXMS for monitoring? For example, I'd like to send the following PowerShell query to my Exchange 2010 server, in order to find out how many e-mails currently are waiting delivery in mail queue:

Get-Queue -Sort-Order:-MessageCount -Result:1 | fl -Property MessageCount

Maybe there is a better solution for what I'm attempting?

Thanks!

Anders

Title: Re: Query PowerShell via Agent
Post by: Victor Kirhenshtein on August 02, 2012, 01:19:16 PM
Hi!

You can define external parameter in agent. Add the following line to your nxagentd.conf:

ExternalParameter = Exchange.MessageCount:powershell -Command "& {Get-Queue -Sort-Order:-MessageCount -Result:1 | fl -Property MessageCount}"

Part before : is a name for new parameter, you can set it whatever you want.

Restart agent, do configuration poll on a node, and you should see new parameter in parameters oist and be able to collect it as any other agent's parameter.

Best regards,
Victor
Title: Re: Query PowerShell via Agent
Post by: Anders on August 04, 2012, 12:57:54 PM
Thank you Victor!