Skip to main content

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!

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/


Thank you, I’ll wait.


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

Tell me if you need anything else


Hello @fmattes,

Will you change this fonctionnality in a near future ? 

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

Regards,


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,


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


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/


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 


You can have a look on this section

About creating a command

About creating a service

 

Hope it helps


@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.


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.


@fmattes Thank you ;)


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


@fmattes : I have problem using it :
 

>2025-09-02 11:03:03.550] 5centreon-monitoring-agent] ndebug] uprocess.cc:192] start process: s"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", "& 'D:\batch\Exit\exit.ps1'; exit LASTEXITCODE", ]
r2025-09-02 11:03:03.553] 5centreon-monitoring-agent] ndebug] uprocess.cc:209] pid:6128 process started: e"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", "& 'D:\batch\Exit\exit.ps1'; exit LASTEXITCODE", ]
r2025-09-02 11:03:03.553] 5centreon-monitoring-agent] ndebug] uprocess.cc:446] fail read from stdout of process e"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", "& 'D:\batch\Exit\exit.ps1'; exit LASTEXITCODE", ]: The pipe has been ended
r2025-09-02 11:03:03.553] 5centreon-monitoring-agent] ndebug] uprocess.cc:506] fail read from stderr of process e"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", "& 'D:\batch\Exit\exit.ps1'; exit LASTEXITCODE", ]: The pipe has been ended
r2025-09-02 11:03:05.192] 9centreon-monitoring-agent] ndebug] uprocess.cc:321] pid:6128 end of process e"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", "& 'D:\batch\Exit\exit.ps1'; exit LASTEXITCODE", ], exit_code=1
r2025-09-02 11:03:05.192] 9centreon-monitoring-agent] ndebug] uscheduler.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


Reply