Sometimes it’s necessary to run powershell scripts on regular time. Just create a normal Windows scheduled job and insert the command below
Ok.. but why this simple action is post? Well sometimes after having run this task the “Task Run Result” shows you that the task has run correctly but not all the commands in your script completed. What’s going on here, man?
Well the task runs correctly, and after the script was executed the OS closes the Powershell session and does not wait.. So to prevent this behaviour (as like at so many Sharepoint cases) let’s insert a start-sleep -seconds 5 command at the end of your pws script 🙂
“powershell scheduled task”