In order to schedule a SharePoint PowerShell script to be run on specific time in Windows Server 2008 R2, perform the following procedures.
- Save your PowerShell script into some folder location with .ps1 extension.
- Create a new task in Windows task scheduler. Specify the user account the PowerShell script to use when running.
- In Actions, add new action of type “Start Program”. In the Program/Script section, provide full path of “PowerShell.exe” file. That is, “C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe”.
- In the Add Arguments field, it needs two arguments. One is the path to SharePoint Administration Console file and the other is the path to your PowerShell script file. This can be provided as follows:
- -PSConsoleFile "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\psconsole.psc1" -Command " & ‘<folder path>\<your script file>.ps1’ "