Showing posts with label Sql Server. Show all posts
Showing posts with label Sql Server. Show all posts

Tuesday, 21 June 2011

Scheduling a SQL Server PowerShell script using the Task Scheduler

Problem

Even if your SQL Server edition does not include the SQL Server Agent service (if you use SQL Express, for instance), you can still automate administration tasks without using any 3rd party products. In this tip I'll describe how to schedule a PowerShell script with the Task Scheduler MMC snap-in. This applies to Windows 2008 Server, Windows 2008 Server R2 and Windows 7.

Solution

Following is the step by step process to setup Task Scheduler to run a PowerShell script. In this example I show how you can backup a database, but this can be applied to any SQL Server task you want to automate and have scheduled on a regular basis.
1. There are several ways to start the Task Scheduler, such as:
  • Go to Start ---> Control Panel ---> Administrative Tools ---> Task Scheduler
  • Go to Start ---> Run ---> Taskschd.msc
  • Go to the Configuration Node of the Server Manager (Windows Server 2008, 2008 R2) or to Computer Manager ---> System Tools (Windows 7 Pro) and click on Task Scheduler