Author Topic: Query PowerShell via Agent  (Read 3511 times)

Anders

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Query PowerShell via Agent
« 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:

Code: [Select]
Get-Queue -Sort-Order:-MessageCount -Result:1 | fl -Property MessageCount
Maybe there is a better solution for what I'm attempting?

Thanks!

Anders


Victor Kirhenshtein

  • Lead Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 7137
    • View Profile
Re: Query PowerShell via Agent
« Reply #1 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

Anders

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: Query PowerShell via Agent
« Reply #2 on: August 04, 2012, 12:57:54 pm »
Thank you Victor!