PowerShell script exchange
Post Reply
shuji
Enthusiast
Posts: 28
Liked: 3 times
Joined: Mar 18, 2016 8:16 pm
Full Name: Ryan
Contact:

Check back copy job is disable or enable

Post by shuji » 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

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

Re: Check back copy job is disable or enable

Post by veremin » 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.

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

Re: Check back copy job is disable or enable

Post by shuji » Apr 22, 2016 5:58 pm

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

Thanks

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

Re: Check back copy job is disable or enable

Post by veremin » Apr 25, 2016 8:35 am

Both internal method and commandlet work exactly the same. Thanks.

nielsengelen
Veeam Software
Posts: 2646
Liked: 546 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re : Check back copy job is disable or enable

Post by nielsengelen » 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 Architect (VMCA)
http://foonet.be

Sand
Influencer
Posts: 24
Liked: never
Joined: Jul 06, 2017 6:07 am
Contact:

[MERGED] Get all disabled VBR Jobs

Post by Sand » 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

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

Re: Check back copy job is disable or enable

Post by veremin » 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.

Sand
Influencer
Posts: 24
Liked: never
Joined: Jul 06, 2017 6:07 am
Contact:

Re: Check back copy job is disable or enable

Post by Sand » 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

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

Re: Check back copy job is disable or enable

Post by veremin » 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.

Sand
Influencer
Posts: 24
Liked: never
Joined: Jul 06, 2017 6:07 am
Contact:

Re: Check back copy job is disable or enable

Post by Sand » Aug 10, 2017 11:50 am

Works great, thanks a lot!

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

Re: Check back copy job is disable or enable

Post by veremin » Aug 10, 2017 11:56 am

You're welcome. Feel free to contact us, if other questions arise. Thanks.

Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests