PoshTip #59 – How to Schedule a PowerShell Script with Arguments?

Scheduling a PowerShell script in the Windows Task Scheduler is not so hard, but when you want to run a script with arguments, it can be a bit tricky. For instance, you could run a script which will send an e-mail, so you would indicate the SMTP server but how can you do it? That’s very simple, let’s see how to perform this task.

Open the Windows Scheduler and create a basic task:

Add a task trigger

I will run this script every day

Select “Start a program

If you work with Windows PowerShell, you must use the following path:

If you work with PowerShell Core, you must use the following path:

Now, you must add arguments with the following syntax:

Be careful with the quotes!

Now, I can add arguments with the full syntax:


Thanks for reading! You can follow me on Twitter @PrigentNico

About Nicolas 270 Articles
I work as an IT Production Manager, based in Paris (France) with a primary focus on Microsoft technologies. I have 10 years experience in administering Windows Servers. . I am a Microsoft MVP for Cloud & Datacenter Management. I also received the PowerShell Hero 2016 award by PowerShell.0rg. And finally, I am "MCSE: Cloud Platform and Infrastructure", "MCSA: Windows Servers", "Administering & Deploying SCCM", and CheckPoint CCSA certified.