Skip to content

mke2023/GetScheduledTaskStatus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

GetScheduledTaskStatus

This script retrieves information of the state of a scheduled task on Windows computers. It uses the powershell cmdlets 'Get-ScheduledTask' and 'Get-ScheduledTaskInfo'. It is written for use with the Advanced EXE/Script Sensor of PRTG Network Monitor. To get this information of a remote host, WinRM needs to be configured. Use 'winrm qc' for a quick configuration on the remote host.

In my environement this script runs reliable. Network with Windows Server Standard 2019, Windows 10 Enterprise, PRTG Network Monitor 23.3.86.1520. Feel free to discuss possible bugs in the discussion area.

Unfortunately the build in sensor 'ScheduledTask2XML' didn't work reliable for me. Finally I think there's a problem with the remote activation of the registry that is required for retrieving the information of the scheduled task on remote computers. Another possibility is to use the COM object 'Schedule.Service' together with 'Invoke-Command' and PSRemoting. This works well for remote computers except for the computer that is running the PRTG Probe. There you need elevated rights to run the script. I've found no way to handle this with the need of returning the results as a console output.

I want to share this and say thanks to all the people that posted their ideas that gave me the possibility to develop this script.

To configure a sensor with this script follow this steps:

  1. Copy this script to '(PRTG Network ProgramDir)\Custom Sensors\EXEXML' (e.g. C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML)
  2. If the sensor is added to a remote computer first configure WinRM on the remote computer: use 'winrm qc' for quick configuration on the remote host (for more information see https://learn.microsoft.com/en-us/windows/win32/winrm/installation-and-configuration-for-windows-remote-management).
  3. Create a new sensor 'EXE/Script Advanced' with the following settings: image

Note: you have to save the Windows account settings that the sensor should use in one of the objects in the device hierarchy. This must be an account with administrative rights on the remote computer.

About

Retrieve the status information of a registered scheduled task in Windows and return the results in Json format for PRTG Network Monitor

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published