O'Reilly logo

SQL Server 2014 with PowerShell v5 Cookbook by Donabel Santos

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Scheduling a SQL Server Job

In this recipe, we will demonstrate how to schedule a SQL Server Job using PowerShell and SMO.

Getting ready

In this recipe, we assume you have a job called Test Job in your development environment that you can run. This was created in the Creating a SQL Server Job recipe. If you do not have this job, pick another job in your system that you can use.

We will schedule this job to run every weekend night at 10 P.M.

How to do it...

Let's look at the steps to schedule a SQL Server Job using PowerShell:

  1. Open PowerShell ISE as administrator.
  2. Import the SQLPS module and create a new SMO Server object:
    #import SQL Server module Import-Module SQLPS -DisableNameChecking #replace this with your instance name $instanceName = "localhost" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required