Run a Powershell script as Scheduled Task

Running a PowerShell script as scheduled task is not as easy as entering PowerShell.exe *script name.ps1*. I have been struggling with it for quite some time.

Here is a command line to get it up and running:

1) Set the execution policy so script are allowed to run, open PowerShell and enter:

Set-executionpolicy -scope currentuser -executionpolicy unrestricted

Choose Y (Yes) to allow scripts to run.

2) Next open scheduled task and enter:

powershell.exe -command "& ‘C:\My Scripts\Backup.ps1’ "

change the name of the script to the name of your script.

 

Now the script will run on the chosen date and time.

 

Can’t get the solution to work? Contact me and let me do the trick.

 

 

 

Advertisements
This entry was posted in Scripts. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s