You are unable to get a Power Shell file to execute using the Task Scheduler
- The execution policy needs to be set to Unrestricted
- The command in Task Scheduler needs to adhere to the correct syntax
- You must store the script in a place PowerShell trusts.
Firstly, store your powershell script in a place PowerShell trusts. To find this, open PowerShell and run:
You will note that one of the safe places is “C:WindowsSystem32”.
Next, Set the execution Policy to Unrestricted using PowerShell. Open PowerShell as administrator and run:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
Press “A” to accept the changes. If you are using a computer account to run the script, you may need to set the execution policy on the local machine to Unrestricted like this:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine
Create a sheduled task as desired. On the actions tab the script must be run like this:
Taking care to wrap the path in double quotes.