Scheduling Scripts

From time to time, it may be useful to have a method to schedule PowerShell scripts to run automatically based on a particular schedule (when the SQL Server Agent isn’t available locally, for example).

You can easily view the method to call PowerShell scripts by simply typing powershell.exe /? from a PowerShell session, as shown here:

image

Only a very small section of the text displayed is shown in this example. The powershell.exe can be used for scheduling regular PowerShell scripts. sqlps.exe works similarly, and you can also access its help by passing a slash and question mark (/?) to the command:

Note

How do you know whether ...

Get Microsoft® SQL Server 2008 R2 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.