PowerShell script exchange
Post Reply
Shralok
Enthusiast
Posts: 51
Liked: 5 times
Joined: Aug 29, 2012 5:36 pm
Full Name: Shralok
Contact:

Getting started with Task Scheduler

Post by Shralok »

I am going to try and use Task Scheduler so that I can tell Veeam what specific time I want my Full Backups to start on the jobs I have which run every 6 hours. Currently the full runs at 17:00 and I have 5 different jobs that are on the same schedule, so I need to space them out.

When using Task Scheduler, I would think I need to somehow "call" PowerShell

I am on the "New Action" portion of the "Create Task" and I am unsure of what to put in. Do I enter the path to my .ps1 file and Windows knows to run it with PowerShell?

Here is my script:

Code: Select all

Get-VBRJob | where {$_.Name –eq “Server1”} | Start-VBRJob -FullBackup
Do I need to add this code since I am not running it from Veeam GUI --> Options --> PowerShell (therefore it doesn't know about the VeeamPSSnapIn to begin with)?

Code: Select all

Add-PSSnapin VeeamPSSnapIn
Slightly confused here... and support told me that they do not support scripting in PowerShell for Veeam... :?: :|

Once I get this figured out, I can turn this into a "FAQ" post that will go over the basics of getting started with Task Scheduler.

Thanks!
veremin
Product Manager
Posts: 20284
Liked: 2258 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Getting started with Task Scheduler

Post by veremin »

In fact, there is a couple of ways how you can achieve your goal. The first is using a scheduled task to run a Windows PowerShell command, and the second scenario is using a scheduled task to run a Windows PowerShell script.

Below you can find list of necessary actions for both of the methods:

1. Command: Call PowerShell, specify the command parameter, and then use the ampersand, a pair of curly brackets, and the Windows PowerShell command you wish to run.

In other words, the Program/Script section should include this line: powershell.
Arguments section: -command &{Add-PSSnapin VeeamPSSnapIn; Get-VBRJob | where {$_.Name –eq “Server1”} | Start-VBRJob –FullBackup;}

Image

2.Script: Program/Script: powershell. Arguments: -file “Your script path”

* Syntax of your script should look like this:

Code: Select all

Add-PSSnapin VeeamPSSnapIn
Get-VBRJob | where {$_.Name –eq “Server1”} | Start-VBRJob –FullBackup
Image

As to the VeeamPSSnapin, it should be called in order to leverage Veeam special methods.

In addition, may I ask what your ticket number is?

Hope this helps.
Thanks.
Shralok
Enthusiast
Posts: 51
Liked: 5 times
Joined: Aug 29, 2012 5:36 pm
Full Name: Shralok
Contact:

Re: Getting started with Task Scheduler

Post by Shralok »

Thank you I will try this today.

Case # 00176538
cmt
Lurker
Posts: 1
Liked: never
Joined: Jan 04, 2017 11:08 am
Full Name: CMT
Contact:

[MERGED] Run current backup job twice or more each day.

Post by cmt »

Hi,

Before writing this topic i have searched this forum to find the answer. But no luck at finding the solution.
I'm currently running Backup & Replication v 9.0.

My question is how do i script my backup job called "Backup VM1" to run daily at 05:00 and 12:00.
If someone could help me making the script with the appropriate schedule options that would be great!

The second step i need help with is how to actually run the script. :roll:
Once i have the right script what do i do with it? Save it to a file and run it with a scheduled task?
Use powershell? :shock:
veremin
Product Manager
Posts: 20284
Liked: 2258 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Getting started with Task Scheduler

Post by veremin »

Check the post above to get the general idea how the script can be triggered via Task Scheduler.

As to the script, use the example mentioned in this thread - just disregard -FullBackup parameter.

Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests