Scheduling a Veeam job using Powershell and 2008 R2 Task Scheduler

I’ve got a number of Veeam replication jobs that I have set up to run on a specific schedule.  On occasion, however, I want the job to run at a specific time outside of the normal schedule.  I can do this using the Veeam snap-in for PowerShell and the 2008 R2 Task Scheduler.

An example would be a replication job scheduled to run daily daily at noon.  That’s easy enough to set up through Veeam, but I may want the initial replication to take place at 1:00 AM, and I don’t want to have to stay up/get up at that time to launch it manually, and I don’t want to have to reconfigure the schedule the next day.  To set this up for ReplicationJob1, for instance, I would take the following steps:

1. I add the following line of code to the global powershell profile (C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1)

Add-PSSnapin VeeamPSSnapIn

This will load the Veeam snapin for PowerShell every time powershell is called, including when it is called from a scheduled task.

2. I create a poweshell script to launch the job. We’ll save it as c:\scripts\run-vbrjob.ps1.  The script code is as follows:


get-vbrjob | ?{$ -eq $jobname} | start-vbrjob -runasync

By parameterizing the script I can use it repeatedly for different jobs.  All I have to do is pass the job name in to the Add arguments section of the task we’re going to set up in the next step. Also worth noting, by using the –runasync switch for the start-vbrjob cmdlet I enable the script to end immediately after sending it’s commands to Veeam.  Doing otherwise would result in a powershell.exe instance being open for the duration of the replication job.  Hardly the end of the world, but no point in wasting resources.

3. I create a new task in the Windows 2008 R2 Task Scheduler with the following settings:

General Tab

   Name: Run-VeeamJob

Security Options

  • When running the task, use the following user account: “sweeneyops\veeam”
  • Run whether user is logged on or not: selected
  • Run with highest privileges: checked

Triggers Tab

  • New…
  • Begin the task: Run task on schedule
  • Settings:  one time, 1:00 AM, 12/13/2011

Action Settings

  • New…
  • Action: “Start Program”
  • Program/Script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
  • Add arguments: “-noninteractive -nologo C:\Scripts\run-vbrjob.ps1 replicationjob1”
  • Start in: “c:\scripts\”

Conditions Tab

  • Defaults

Settings Tab

  • Defaults
  1. Your solution is very cool.
    Thanks very much :->

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: