Skip to main content
Question

Custom Script for Monitoring Scheduled Tasks on Windows Agent (CMA)

  • August 18, 2025
  • 14 replies
  • 175 views

Forum|alt.badge.img+1

Hi everyone,


I’d like to create a custom script for the Windows Agent (CMA) to monitor the status of scheduled tasks (success, failure, duration, etc.).


Does anyone have PowerShell script examples to get started?


Thanks in advance for your feedback and best practices!

14 replies

fmattes
Centreonian
Forum|alt.badge.img+10
  • Centreonian
  • August 18, 2025

Hi, 

You can, of course, use a custom script for specific needs, but you may be happy to now that we will provide a native Task Scheduler CMA check with the August connectors release, which will be delivered in 1-2 days.

Just have a look here : https://docs.centreon.com/pp/integrations/plugin-packs/releases/release-notes/


Forum|alt.badge.img+1
  • Author
  • Steward *
  • August 18, 2025

Thank you, I’ll wait.


fmattes
Centreonian
Forum|alt.badge.img+10
  • Centreonian
  • August 27, 2025

Hi  ​@Noemie , Task Scheduler for CMA is now available.

Tell me if you need anything else


Forum|alt.badge.img+3
  • Steward *
  • September 1, 2025

Hello @fmattes,

Will you change this fonctionnality in a near future ? 

Because, Tasks Scheduler is not really intuitive way to monitore Windows Server.

Regards,


fmattes
Centreonian
Forum|alt.badge.img+10
  • Centreonian
  • September 1, 2025

Hello @fmattes,

Will you change this fonctionnality in a near future ? 

Because, Tasks Scheduler is not really intuitive way to monitore Windows Server.

Regards,

Hi ​@lolokai ,

Not sure i understand well your question.

There are plenty other checks to monitor WIndows Server (see https://docs.centreon.com/pp/integrations/plugin-packs/procedures/operatingsystems-windows-centreon-monitoring-agent/)

What other way than Task Scheduler are you suggesting to monitor Tasks on Windows Server ?

Regards,


Forum|alt.badge.img+3
  • Steward *
  • September 1, 2025

@fmattes : I would like to monitor using custom power shell 


fmattes
Centreonian
Forum|alt.badge.img+10
  • Centreonian
  • September 1, 2025

Yous should already be able to do that, did you try to follow this procedure ? https://docs.centreon.com/pp/integrations/plugin-packs/getting-started/how-to-guides/cma/cma-custom/


Forum|alt.badge.img+3
  • Steward *
  • September 1, 2025

Sorry I don’t understandard anything. I must create a command on the central server ? Where ? And how to apply it to a service ? ​@fmattes 


fmattes
Centreonian
Forum|alt.badge.img+10
  • Centreonian
  • September 1, 2025

You can have a look on this section

About creating a command

About creating a service

 

Hope it helps


Forum|alt.badge.img+3
  • Steward *
  • September 2, 2025

@fmattes My question is just should I use OS-Windows-Centreon-Monitoring-Agent-custom as Service Template and create a custom command into Centreon link it to this template to work ?

Because is not usual to create a powershell command into Centreon.


fmattes
Centreonian
Forum|alt.badge.img+10
  • Centreonian
  • September 2, 2025

Hi,

It is not necessary to use OS-Windows-Centreon-Monitoring-Agent-custom as Service Template.

You can create your own fresh new Service Template & command, and associate the service to the Host linked with CMA.

The command need to be associated (“connector” field) with “Centreon Monitoring Agent” connector in order to be handled as a CMA command and sent to the Agent.


Forum|alt.badge.img+3
  • Steward *
  • September 2, 2025

@fmattes Thank you ;)


Forum|alt.badge.img+3
  • Steward *
  • September 2, 2025

@fmattes For Powershell a Write-Host is working for print the service output inside Centreon ?


Forum|alt.badge.img+3
  • Steward *
  • September 2, 2025

@fmattes : I have problem using it :
 

[2025-09-02 11:03:03.550] [centreon-monitoring-agent] [debug] [process.cc:192] start process: ["C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", "& 'D:\batch\Exit\exit.ps1'; exit LASTEXITCODE", ]
[2025-09-02 11:03:03.553] [centreon-monitoring-agent] [debug] [process.cc:209] pid:6128 process started: ["C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", "& 'D:\batch\Exit\exit.ps1'; exit LASTEXITCODE", ]
[2025-09-02 11:03:03.553] [centreon-monitoring-agent] [debug] [process.cc:446] fail read from stdout of process ["C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", "& 'D:\batch\Exit\exit.ps1'; exit LASTEXITCODE", ]: The pipe has been ended
[2025-09-02 11:03:03.553] [centreon-monitoring-agent] [debug] [process.cc:506] fail read from stderr of process ["C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", "& 'D:\batch\Exit\exit.ps1'; exit LASTEXITCODE", ]: The pipe has been ended
[2025-09-02 11:03:05.192] [centreon-monitoring-agent] [debug] [process.cc:321] pid:6128 end of process ["C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", "& 'D:\batch\Exit\exit.ps1'; exit LASTEXITCODE", ], exit_code=1
[2025-09-02 11:03:05.192] [centreon-monitoring-agent] [debug] [scheduler.cc:333] end check for service Script-Exit command C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& 'D:\batch\Exit\exit.ps1'; exit LASTEXITCODE"

 

I already used Write-Host and Write-Output inside my Powershell script