Check back copy job is disable or enable

PowerShell script exchange

Check back copy job is disable or enable

Veeam Logoby shuji » Fri Apr 22, 2016 4:12 pm

Hi there,

Is there any way to check a back copy job is disabled or enabled?
I need to know the status of the job, so I can run the rest of the script smoothly.

Thank you

Ryan
shuji
Enthusiast
 
Posts: 27
Liked: 3 times
Joined: Fri Mar 18, 2016 8:16 pm
Full Name: Ryan

Re: Check back copy job is disable or enable

Veeam Logoby v.Eremin » Fri Apr 22, 2016 4:50 pm

Try the following example:

Code: Select all
$Job = Get-VBRJob -Name "Name of backup to tape job"
$Job.info.IsScheduleEnabled


Thanks.
v.Eremin
Veeam Software
 
Posts: 13293
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Check back copy job is disable or enable

Veeam Logoby shuji » Fri Apr 22, 2016 5:58 pm

Just a further question:
what is difference between $Job.EnableScheduler() and Enable-VBRJob ?

Thanks
shuji
Enthusiast
 
Posts: 27
Liked: 3 times
Joined: Fri Mar 18, 2016 8:16 pm
Full Name: Ryan

Re: Check back copy job is disable or enable

Veeam Logoby v.Eremin » Mon Apr 25, 2016 8:35 am

Both internal method and commandlet work exactly the same. Thanks.
v.Eremin
Veeam Software
 
Posts: 13293
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re : Check back copy job is disable or enable

Veeam Logoby vmniels » Mon Apr 25, 2016 12:22 pm

The following will see if the job is stopped (disabled) or not (running):
Code: Select all
$job = Get-VBRJob -Name "BACKUPCOPYJOBNAME"

if (!$job.IsStopped()) {
    Write-Output "Enabled"
} else {
    Write-Output "Disabled"
}
VCP-DCV
Veeam Certified Engineer
http://foonet.be
vmniels
Veeam Software
 
Posts: 1518
Liked: 328 times
Joined: Mon Jul 15, 2013 11:09 am
Full Name: Niels Engelen

[MERGED] Get all disabled VBR Jobs

Veeam Logoby Sand » Thu Aug 10, 2017 9:28 am

Hi

I need help getting all disabled VBR Jobs and displaying them together with the job description. I cannot find a state or "isDisabled" member of a VBRJOB or VBRSession, and "isStopped" applies to all stopped jobs - which are all that are not failed.

Thanks for your help
Sand
Novice
 
Posts: 5
Liked: never
Joined: Thu Jul 06, 2017 6:07 am

Re: Check back copy job is disable or enable

Veeam Logoby v.Eremin » Thu Aug 10, 2017 9:52 am

Try the example provided above. As to description, you can find it here:

Code: Select all
asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Name of your job"
$Job.info.Description


Thanks.
v.Eremin
Veeam Software
 
Posts: 13293
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Check back copy job is disable or enable

Veeam Logoby Sand » Thu Aug 10, 2017 11:27 am

Thanks for your reply.
Somehow I still cannot get it to work:

Using this

Code: Select all

$job = Get-VBRJob -name "Backup Job Name"
$Job.info.IsScheduleEnabled()



I get the error
[Veeam.Backup.Model.CDbBackupJobInfo] does not contain a method named 'IsScheduleEnabled'.

When I try this

Code: Select all
if (!$job.IsStopped()) {
    Write-Output "Enabled"
} else {
    Write-Output "Disabled"
}


I get "Disabled" for all Jobs currently not running. But I would need only the disabled ones.

I then tried something like this
Code: Select all
$jobs = Get-VBRJob |Get-VBRJobScheduleOptions| where{$_.NextRun -eq ""}


Which seems to work, but I am not good enough on powershell to then check the VBRJob Members against anything - I only have the JobSchedule Object in this case.

Any help appreciated
Sand
Novice
 
Posts: 5
Liked: never
Joined: Thu Jul 06, 2017 6:07 am

Re: Check back copy job is disable or enable

Veeam Logoby v.Eremin » Thu Aug 10, 2017 11:44 am

Try to rewrite original script slightly:

Code: Select all
Get-VBRJob | where {$_.IsScheduleEnabled -eq $False} | select name, {$_.info.description}

Thanks.
v.Eremin
Veeam Software
 
Posts: 13293
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Check back copy job is disable or enable

Veeam Logoby Sand » Thu Aug 10, 2017 11:50 am

Works great, thanks a lot!
Sand
Novice
 
Posts: 5
Liked: never
Joined: Thu Jul 06, 2017 6:07 am

Re: Check back copy job is disable or enable

Veeam Logoby v.Eremin » Thu Aug 10, 2017 11:56 am

You're welcome. Feel free to contact us, if other questions arise. Thanks.
v.Eremin
Veeam Software
 
Posts: 13293
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 10 guests