scheduling powershell script
Posted on 2014-01-27
I'm trying to schedule a task with a powershell script.
I scheduled this;
powershell.exe -Command c:\scripts\deleteoldfiles.ps1
It works. However, I don't like to make execution policy for local machine to unrestricted. So I did this;
Then I changed scheduled task to;
powershell.exe -Command c:\scripts\deleteoldfiles.ps1 -ExecutionPolicy ByPass
This doesn't work. I selected 'run with highest privileges' in the task, unblocked the script, still doesn't work.
Windows 2012 server