PowerShell script exchange
Post Reply
thethommyy
Influencer
Posts: 17
Liked: 3 times
Joined: Apr 12, 2018 3:16 pm
Full Name: KDV Support
Contact:

automatically disable/enable Jobs

Post by thethommyy »

Hello,

I know that this post is very old, but I've a question:

I would like to enable / disable automaticly a backupjob with powershell.

Is this the right powershell script:

asnp VeeamPSSnapin
xyJob.DisableScheduler()
respectively
xyJob.EnableScheduler()

We run VB&R 9.5 on a Windows 2012R2-Server.

Thank you !
Thomas
ravatheodor
Veeam Software
Posts: 14
Liked: 4 times
Joined: Dec 22, 2016 1:07 pm
Full Name: Razvan Ionescu
Contact:

Re: automatically disable/enable Jobs

Post by ravatheodor »

Hi Thomas,
For 9.5 U3 there are powershell cmdlets available - Enable-VBRJobSchedule and Disable-VBRJobSchedule. Script would like this:

Code: Select all

Get-VBRJob -Name "My Backup Job Name" | Enable-VBRJobSchedule
Please have a look at this post also https://forums.veeam.com/powershell-f26 ... 47762.html
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: automatically disable/enable Jobs

Post by veremin »

The script above disables/enables job schedule. If you'd like to enable/disable job itself, you should Enable-VBRJob and Disable-VBRJob cmdlets instead. Thanks.
thethommyy
Influencer
Posts: 17
Liked: 3 times
Joined: Apr 12, 2018 3:16 pm
Full Name: KDV Support
Contact:

Re: automatically disable/enable Jobs

Post by thethommyy »

Good Morning,

thank you very much, I'll try it.

Thomas
thethommyy
Influencer
Posts: 17
Liked: 3 times
Joined: Apr 12, 2018 3:16 pm
Full Name: KDV Support
Contact:

Re: automatically disable/enable Jobs

Post by thethommyy »

Hello,

it works, but how can I start this Veeam-Powershell-script by a Windows Batch file ?
My goal is to create a Windows batch file that runs in the morning and evening to enable / disable a Veeam backup Job.

Thank you !
Thomas
thethommyy
Influencer
Posts: 17
Liked: 3 times
Joined: Apr 12, 2018 3:16 pm
Full Name: KDV Support
Contact:

Re: automatically disable/enable Jobs

Post by thethommyy »

Hello,

I think / hope I've got it:

the PS1-Script:
Add-PSSnapin -Name VeeamPSSnapIn
Get-VBRJob -Name "My Backup Job" | Disable-VBRJob

I start this PS1-script by a Windows Batch file.

The Problem is, this script has to start by Admin and I have to Change the HKEY_LOCAL_MACHINE\SOFTWARE\Veeam\Veeam Backup and Replication permissions ......

Thomas
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: automatically disable/enable Jobs

Post by veremin »

Correct, admin account or permission on certain registry hives is necessary.

You're also right that before using any Veeam specific cmdlet you need to add our snap-in, using Add-PSSnapin cmdlet.

Thanks.
mfirewalker
Influencer
Posts: 23
Liked: 4 times
Joined: Jul 07, 2017 9:58 am
Contact:

Re: automatically disable/enable Jobs

Post by mfirewalker »

Is there a simple way to disable/enable tape jobs (GFS) in PowerShell? It seems like I always have to remember (save) the current schedule and pass it along Set-VBRBackupToTapeJob using New-VBRBackupToTapeScheduleOptions to re-enable a tape job in PowerShell. I basically want to achieve the same as disabling and re-enabling the job in the GUI.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: automatically disable/enable Jobs

Post by veremin »

Do you want to enable/disable particular GFS retention policy part like weekly, monthly, yearly, etc.? Or you want to enable/disable GFS tape job? In this case doesn't it respect standard enable/disable-vbrjob cmdlets - don't have a console at hand to check? Thanks!
mfirewalker
Influencer
Posts: 23
Liked: 4 times
Joined: Jul 07, 2017 9:58 am
Contact:

Re: automatically disable/enable Jobs

Post by mfirewalker »

I want to disable/enable the entire job. Guess what, you are right. I can pass the Get-VBRTapeJob to Disable-VBRJob, works just fine. I thought because Get-VBRJob in the Managing jobs part in the reference does not return tape jobs and because Disable-VBRJob in the reference to only state "You can run this cmdlet with backup, replication and copy jobs." that I cannot use Disable-VBRJob with tape jobs. So yes, you can run Disable-VBRJob against a tape job as well. Thank you for making me try to most obvious solution :D
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: automatically disable/enable Jobs

Post by veremin »

You're welcome. I was almost scary to find that to enable and disable tape job one needs to modify and apply tape job schedule :) Good to know it did't come true. Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests