Thursday, January 17, 2013

Running a powershell script as a Scheduled Task

I found this link to run a powershell script using the Task Scheduler.

To create a simple task to copy a directory from one location to another.Open task scheduler and click Create Basic task.Give the name as Copy task. You can specify and select whether you want to run the task only when you login or keep it running whether a user logs in or not. Once that is done then click the Actions tab and click new. Let the Action be as Start a program. In the Settings text box enter this.


And in the Add arguments enter this after replacing the script path.

–Noninteractive –Noprofile –Command "&{Path to your Script}"

Open notepad and edit the Script file. Enter these lines and save it.

copy-item c:\yourfolderpath -destination c:\destinationpath -recurse

You can start the task and check if the copy is happening. Check the folder permissions and don't add any spaces in the directory names if your copy is not working.

No comments:

Post a Comment