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 »

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: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get Backup Job Schedule and Repository

Post by veremin »

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 »

Yes, all jobs are either daily or weekly at the moment.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get Backup Job Schedule and Repository

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

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 »

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: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get Backup Job Schedule and Repository

Post by veremin »

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 »

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: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get Backup Job Schedule and Repository

Post by veremin »

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 »

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 »

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: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get Backup Job Schedule and Repository

Post by veremin »

Hi, David,

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

Thanks.
marius roma
Veteran
Posts: 459
Liked: 5 times
Joined: Feb 01, 2012 12:04 pm
Full Name: Mario
Contact:

[MERGED] List jobs by start time

Post by marius roma »

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
Veteran
Posts: 459
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 »

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: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get Backup Job Schedule and Repository

Post by veremin » 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
Veeam Legend
Posts: 879
Liked: 46 times
Joined: Nov 05, 2009 12:24 pm
Location: Sydney, NSW
Contact:

Re: Get Backup Job Schedule and Repository

Post by albertwt »

Any update please?
--
/* Veeam software enthusiast user & supporter ! */
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get Backup Job Schedule and Repository

Post by veremin »

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!
Leo0601
Enthusiast
Posts: 39
Liked: 2 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: Get Backup Job Schedule and Repository

Post by Leo0601 »

Hi Experts,

I have one question.

When there is more than one Backup repositories in Veeam backup sever, creating backup job using powershell scripts is failing. Is it any limitations ?

If its not possible can you please share the link.

Looking forward to hear from you.

Regards
Leo.
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Get Backup Job Schedule and Repository

Post by oleg.feoktistov » 1 person likes this post

Hi Leo,

I'm not quite sure what you are trying to achieve. If you are aiming to add a single repository to a job, might be the case that you obtain a list of repositories and try to add them all as a target for your backup job instead of adding just one.
In this case, use more filters to get the needed repo. Example:

Code: Select all

$targetRepo = Get-VBRBackupRepository -Name 'Backup Repository'
Or:

Code: Select all

$targetRepo = Get-VBRBackupRepository | where {$_.Description -eq 'for primary backups'}
If it isn't the issue, please, share your code so that we could help you further.

Thanks,
Oleg
Leo0601
Enthusiast
Posts: 39
Liked: 2 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: Get Backup Job Schedule and Repository

Post by Leo0601 »

Hi Oleg,

$targetRepo = Get-VBRBackupRepository | where {$_.Description -eq 'for primary backups'} - this is what I am expecting thanks much. Very helpful. I will upvote your answer now itself.

I have one more query for the below link which you have already replied me. I am just waiting for your reply. Kindly help me.
powershell-f26/help-with-veeam-10-unatt ... 74486.html

Regards
Leo
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests