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 »

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: 20400
Liked: 2298 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 »

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 »

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

Thanks
veremin
Product Manager
Posts: 20400
Liked: 2298 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 »

Both internal method and commandlet work exactly the same. Thanks.
nielsengelen
Product Manager
Posts: 5796
Liked: 1215 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 »

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"
}
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
Sand
Influencer
Posts: 24
Liked: never
Joined: Jul 06, 2017 6:07 am
Contact:

[MERGED] Get all disabled VBR Jobs

Post by Sand »

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: 20400
Liked: 2298 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 »

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 »

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: 20400
Liked: 2298 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 »

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 »

Works great, thanks a lot!
veremin
Product Manager
Posts: 20400
Liked: 2298 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 »

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

Who is online

Users browsing this forum: No registered users and 19 guests