Creating a Scheduled Task to Execute a Custom PowerShell Script via EXE

Modified on Fri, 1 Aug at 12:53 AM

Objective


There are several scenarios where scheduled tasks need to be set up on Windows devices to run automation scripts at defined intervals or triggers. In this use case, we walk through creating a custom scheduled task that runs a PowerShell script — converted into an executable (.exe) — using Software Deployment combined with the Add Scheduled Program feature.


Overview of the Process

To achieve this setup, follow these key steps:

  1. Convert PowerShell Script to EXE
    Use a utility like PS2EXE or IExpress to convert your PowerShell script (.ps1) into a .exe file.
    In this example, we converted a script that retrieves Windows Update logs (Get-WindowsUpdateLog.ps1) into an executable.

  2. Deploy the Executable via Software Deployment

    • Go to EM > Actions > Software Deployment

    • Upload and assign the .exe file to target systems

    • Deploy the file across your selected endpoints

  3. Schedule Execution via “Add Scheduled Program”

    • Navigate to EM > Actions >Startup Programs > Add Scheduled Program

    • Select the deployed .exe file(ie the path to where you have deployed)

    • Define the schedule, trigger (e.g., Daily, at a specific time), and optional conditions (e.g., Run whether user is logged on or not)

Creation of the scheduled task via the EM console


Example Use Case

Script Functionality:
We used a PowerShell script that generates WindowsUpdate.log. After converting it to EXE and deploying it:

  • The EXE was successfully triggered via a scheduled task

  • The expected logs were generated on the target device

  • This confirms the EXE ran successfully in the scheduled time slot


Output from the task execution, confirming log generation



Conclusion

 

Using the Software Deployment module along with the Add Scheduled Program option offers a simple and effective way to automate script execution on Windows devices. It's a practical method for running tasks like log generation or cleanups and can be easily adapted for similar automation needs.

Ask ChatGPT


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article