PowerShell script exchange
Post Reply
rsarnold1s
Influencer
Posts: 11
Liked: never
Joined: May 05, 2016 10:33 pm
Contact:

Get Backup Job Schedule and Repository

Post by rsarnold1s » Aug 29, 2016 10:20 pm

Hi All-

Our IT Team has an intranet site that I am currently writing documentation for. What I am doing is creating a html table that will show job name, vms in job, job schedule and job repository. So far I have a simple script that lists jobs and vms in job:

Code: Select all

Add-PSSnapin VeeamPSSnapin
Connect-VBRServer -Server MyServer
$Jobs = Get-VBRJob
Foreach($Job in $Jobs)
{
    $JobName = $Job.Name
    $Objects = $Job.GetObjectsInJob()
    $Objects.Name
    $JobName

}
Disconnect-VBRServer
I have been messing around with Get-VBRJobScheduleOptions, but it doesn't look good when displayed in a table. All I want to get is the days that the job runs and also the backup repository. Is there an easy way to do this?

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

Re: Get Backup Job Schedule and Repository

Post by veremin » Aug 30, 2016 10:54 am

Do all jobs have more or less similar scheduler (like, daily, monthly with active full scheduled for particular day, etc.)? If yes, which one?

I'm wondering because having similarities in schedules should make a potential script simpler.

Thanks.

rsarnold1s
Influencer
Posts: 11
Liked: never
Joined: May 05, 2016 10:33 pm
Contact:

Re: Get Backup Job Schedule and Repository

Post by rsarnold1s » Aug 30, 2016 2:25 pm

Yes, all jobs are either daily or weekly at the moment.

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

Re: Get Backup Job Schedule and Repository

Post by veremin » Aug 31, 2016 10:01 am 1 person likes this post

Try the following example and see whether it answers your requirements:

Code: Select all

Get-VBRJob | where {$_.JobType -eq "Backup"} | Select-Object -Property @{N="Name";E={$_.Name}}, @{N="Schedule Type";E={$_.ScheduleOptions.OptionsDaily.kind}}, @{N="Scheduled Days";E={$_.ScheduleOptions.OptionsDaily.DaysSrv}}, @{N="Scheduled Days";E={$_.ScheduleOptions.OptionsDaily.DaysSrv}}   
Thanks.

rsarnold1s
Influencer
Posts: 11
Liked: never
Joined: May 05, 2016 10:33 pm
Contact:

Re: Get Backup Job Schedule and Repository

Post by rsarnold1s » Aug 31, 2016 6:38 pm

Thanks Eremin, I was able to get it to work in the Powershell console.

Code: Select all

Add-PSSnapin VeeamPSSnapin
Connect-VBRServer -Server myserver
$Jobs = Get-VBRJob
Foreach($Job in $Jobs)
{
    $JobName = $Job.Name
    $Objects = $Job.GetObjectsInJob()
    $RestorePoints = Get-VBRRestorePoint -Backup $JobName
    $Day = $Job.ScheduleOptions.OptionsDaily.DaysSrv
    
    $RP = $RestorePoints.Count
    $VM = $Objects.Name
    
    $Body += "<tr>"
    $Body += "<td>$JobName</td>"
    $Body += "<td>$VM</td>"
    $Body += "<td>$RP</td>"
    $Body += "<td>$Day</td>"
    $Body += "</tr>"

}
Disconnect-VBRServer

Return $Body
Just a couple more questions:

1. My web server is using WAMP 32-bit and it looks like the Veeam PS module is 64-bit. How can I get this module registered for 32-bit?
2. I've been looking but haven't found a command that shows the time when the backup starts. Can you direct me to the correct resource?

Again, thank you.

rsarnold1s
Influencer
Posts: 11
Liked: never
Joined: May 05, 2016 10:33 pm
Contact:

Re: Get Backup Job Schedule and Repository

Post by rsarnold1s » Aug 31, 2016 9:42 pm

Just an update, been messing around with different commands and have found something that is working pretty well at the moment.

Code: Select all

$Session = New-PSSession -ComputerName myserver
    Invoke-Command -Session $Session -ScriptBlock{
        Add-PSSnapin VeeamPSSnapin
        $VbrJobs = Get-VBRJob | Sort-Object typetostring, name
        $Repos = Get-VBRBackupRepository
        
        Foreach($Job in $VbrJobs)
        {
            #Get Job Name
            $JobName = $Job.Name
            
            #Get VMs in Job
            $Objects = $Job.GetObjectsInJob()

            #Get Restore Points
            $RP = $Job.GetOptions().backupstorageoptions.retainCycles

            #Get Days
            $Day = $Job.ScheduleOptions.OptionsDaily.DaysSrv
            $Freq = $Job.ScheduleOptions.OptionsDaily.kind

            If($Freq -eq "Everyday")
            {
                $Day = "Everyday"
            }

            #Get Backup Repository Name
            $RepoTarget = $Job.FindTargetRepository()
            $RepoTarget = $RepoTarget.Name
            
            #Get VM Name    
            $VM = $Objects.Name

            #Get Last Backup
            $Backup = Get-VBRBackup | Where{$_.JobName -eq "$JobName"}
            $LastBackup = $Backup.LastPointCreationTime
                  
    
            $Body += "<tr>"
            $Body += "<td>$JobName</td>"
            $Body += "<td>$VM</td>"
            $Body += "<td>$RP</td>"
            $Body += "<td>$Day</td>"
            $Body += "<td>$RepoTarget</td>"
            $Body += "<td>$LastBackup</td>"
            $Body += "</tr>"


        }
    
    Return $Body
}
This is a work-around for my WAMP server trying to run Powershell in 32-bit mode, but using the Invoke-Command method I get flooded with "WARNING: You should update your PowerShell to PowerShell 2.0 version" messages. My OS is server 2012 running Powershell v5. Anyway to prevent those messages?

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

Re: Get Backup Job Schedule and Repository

Post by veremin » Sep 01, 2016 9:54 am

Just to confirm - you're executing the script on a machine running 32-bit OS and, thus, getting tons of the said warnings? Thanks.

rsarnold1s
Influencer
Posts: 11
Liked: never
Joined: May 05, 2016 10:33 pm
Contact:

Re: Get Backup Job Schedule and Repository

Post by rsarnold1s » Sep 01, 2016 4:48 pm

Sorry, should have been more specific on my environment.

OS: Server 2012 64-bit Powershell v5 installed
WAMP 32-bit is installed on the server.
Processes are run as 32-bit from the WAMP web server. Looks like the Veeam Powershell module is 64-bit only, as a work-around I used the Invoke-Command to connect to my Veeam server to run the command.
However, here is a sample output I am getting using the code posted above. The script works fine, it's just that these warnings appear before any data is output.

Code: Select all

PS C:\Windows\system32> C:\Veeam.ps1
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
WARNING: You should update your PowerShell to PowerShell 2.0 version.
Normally the warnings wouldn't be an issue, but this is displayed on my web report:

Image

I think this issue could be resolved if I could register the Veeam PS module for 32-bit so I don't have to use the Invoke-Command method. Do you know if this is possible?

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

Re: Get Backup Job Schedule and Repository

Post by veremin » Sep 01, 2016 8:48 pm

I don't think at is, since PS snap-in in now a part of VB&R console and that requires 64-bit OS in its turn. Thanks.

ePowerIT
Novice
Posts: 4
Liked: never
Joined: Jun 22, 2017 9:09 pm
Full Name: David Dowle
Contact:

[MERGED] Retain Restore Points

Post by ePowerIT » Jul 11, 2017 8:36 pm

Hi Guys,

I am missing something obvious,

I am trying to get the number of restore points a job is set to retain. I thought I would find this within the get-vbrjob, or get Get-VBRJobScheduleOptions cmdlets, but can't seem to see them.

Am I being silly?

Thanks

David

ePowerIT
Novice
Posts: 4
Liked: never
Joined: Jun 22, 2017 9:09 pm
Full Name: David Dowle
Contact:

[MERGED] Full / Incremental

Post by ePowerIT » Jul 11, 2017 8:36 pm

Guys,

Is there a way to find out from Get-VBRJobScheduleOptions (or other cmdlet) when full and incremental backups are set for?

Thanks

David

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

Re: Get Backup Job Schedule and Repository

Post by veremin » Jul 12, 2017 1:03 pm

Hi, David,

Kindly, check the examples above and ask for additional help, if needed.

Thanks.

marius roma
Expert
Posts: 450
Liked: 5 times
Joined: Feb 01, 2012 12:04 pm
Full Name: Mario
Contact:

[MERGED] List jobs by start time

Post by marius roma » Jul 12, 2017 1:13 pm

I need to extract a list of replica jobs and, for each job, I need to list the scheduling information, i.e. job1 is scheduled to start every monday at 22:00, job 2 is scheduled to start every day at 22:30, and so on.
Is there any sample I can start from?
Regards
marius

marius roma
Expert
Posts: 450
Liked: 5 times
Joined: Feb 01, 2012 12:04 pm
Full Name: Mario
Contact:

Re: Get Backup Job Schedule and Repository

Post by marius roma » Oct 18, 2018 3:25 pm

I apologize for the very basic question.
Using the code in the previous posts I am able now to get lots of information about a job except the start time.
Given that:

Code: Select all

$Day = $Job.ScheduleOptions.OptionsDaily.DaysSrv
returns the day, how can I get the time, i.e. 22:30?
Regards
marius

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

Re: Get Backup Job Schedule and Repository

Post by veremin » Oct 23, 2018 12:03 pm 1 person likes this post

Does this script answer your requirements?

Code: Select all

Asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Name of your backup job"
$Job.ScheduleOptions.OptionsDaily.TimeLocal
Thanks!

albertwt
Expert
Posts: 640
Liked: 20 times
Joined: Nov 05, 2009 12:24 pm
Location: Sydney, NSW
Contact:

Re: Get Backup Job Schedule and Repository

Post by albertwt » Feb 20, 2019 6:17 am

Any update please?
--
/* Veeam software enthusiast user & supporter ! */

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

Re: Get Backup Job Schedule and Repository

Post by veremin » Feb 20, 2019 10:46 am

What update you're looking for?

May I ask not to post the same question into multiple threads, if you want to find a specific script and not sure whether it's been written already or not, it's always recommended to create a separate thread and let moderators merge it into the existing discussion.

Thank you for understanding!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests