How to schedule Powershell script to run in task scheduler
Yes, you can easily schedule .bat scripts, but how about scheduling a PowerShell script to run via the Windows task scheduler? Let’s do that quickly.
1. Step Before you can run your own Powershell scripts you to run the Powershell as administrator and change the Execution Policy. We have prepared a tutorial for you. Read this: Powershell script cannot be loaded because the execution of scripts is disabled on this system
Basically, run as admin and enter Set-ExecutionPolicy RemoteSigned
Saving PowerShell Script as .PS1 File
2. Step Now copy your Powershell script into a text file and save it as a .ps1 file – If you are new to Powershell, you might want to read our tutorial How to save powershell scripts
3. Step Click on File, Save as
4. Step When you save the file enter a name and add “.ps1”, from the dropdown select “All files” (important step)
Creating Batch Script To Schedule Powershell script
5. StepOpen the notepad and insert:
powershell -command C:\path\script.ps1
Replace C:\path with your own path
6. Step Save the file as a .bat file similar to step 4 but add “.bat”
7. Open the Windows task schedule and schedule the .bat file
8. StepIf you don’t know how to schedule bat files in Windows 7, read our tutorial how to schedule tasks in Windows 7
Open the task scheduler and add the bat file (Actions)