PowerShell script exchange
tcz
Lurker
Posts: 1
Liked: 1 time
Joined: Jun 27, 2018 8:47 pm
Full Name: Thomas Czarnetzki
Contact:

[MERGED] VM-Backups completed in JOB

Post by tcz » 1 person likes this post

Dear,

i need a powershell-script who returns me, who many VMs/Backups in a Job are completed/running.
I have found in the Forum the following snipped, who list me the VMs in a Job - that works fine:

Code: Select all

Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue

$jobname = "xyz"

# Get entire vCenter VM hierarchy using VM and Template view for object [ath
$vmsandtemplates = Find-VBRViEntity -VMsAndTemplates
$vmfoldertree = $vmsandtemplates |? {$_.Type -eq "Vm"}
$vmfolders = $vmsandtemplates |? {$_.Type -eq "Folder"}

# Get Backup Job
$job = Get-VBRJob -Name $jobname | Sort -Property Name

write-Host $job.Name
# Get all included objects in job (assumes single folders)
$jobobjs = $job.GetObjectsInJob() | ?{$_.Type -eq "Include"}
# Get path for folder object
$jobobjid = $jobobjs.GetObject().Info.HostId.ToString() + "_" + $jobobjs.GetObject().Info.ObjectId
$jobobjpath = ($vmfolders | ?{$_.Id -eq "$jobobjid"}).Path
write-host $jobobjpath
# Get subset of VMs that are in the folder
$vmsinfolder= $vmfoldertree |?{$_.Path -like "$jobobjpath*"} | Sort -Property Name

ForEach ($vm in $vmsinfolder) {
    write-host "   " $vm.Name
}
But who i can now receive the info, when the lastbackup of vm is finished, or currently running?
For the Job i have found a lot of solutions, but i need the info for VMs in a job.

Target-Output is, e.g. "13 of 35 VMs completed in Job xyz".

Kind regards,
tcz
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: My Veeam Report v9.5.1

Post by veremin »

The report provided above should have information you're after. Thanks!
jochot
Expert
Posts: 109
Liked: 5 times
Joined: Jul 13, 2017 12:34 pm
Contact:

[MERGED] Reporting with Powershell (Sessions? Jobs?)

Post by jochot »

Hey,

I'd like to use powershell to create Reports for our Auditers.
Now I know that this is a Job for VeeamONE, but we don't have VeeamONE.
The report needs to show that the backup for a Job or VM ran on a daily basis between date X and Y & I would like to have additional info for failed jobs.
Basically a List with the following infos: [Jobname, BackupStart, BackupEnd, Result]

My two approaches up until now are:
JobObject:

Code: Select all

$JobName = "asdf" 
$JobObj = Get-VBRJob -name $JobName 
$lastBaseSession = $JobObj.FindLastBaseSession() 
echo $lastBaseSession
Here I get the latest results from the backup job, so from the latest run, haven't found a way to get more than one session displayed

Sessions:

Code: Select all

$VbrJobSessions = Get-VBRBackupSession -Name $Jobname
echo $VbrJobSessions
Here I get the first session returned.

As I understand it, a Session is one backup run, so I should have one session per day (daily backup)
I would assume, that you get all the sessions in $VbrJobSessions for $Jobname & can foreach($JobSession in $VbrJobSessions) through all the Sessions & fetch the info you need from the sessions for each day, but that doesn't seem to work.
(https://helpcenter.veeam.com/docs/backu ... l?ver=95u4 "Returns jobs sessions." 'Sessions' -> plural, but could also mean latest Sessions for all jobs?)

Does anyone know where I can find history info about a Job or a VM in Powershell? Am I missing something?
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: My Veeam Report v9.5.1

Post by veremin »

Kindly, check the report above - should answer your requirements.

Search this subforum in case it does not - there are multiple threads talking about the very same matter.

Thanks!
jochot
Expert
Posts: 109
Liked: 5 times
Joined: Jul 13, 2017 12:34 pm
Contact:

Re: My Veeam Report v9.5.1

Post by jochot »

had a look, that's 3000lines of powershell code, I honestly don't have a clue where to start looking in this script to find what I need.
I just want to have a history of Backup Sessions for one Backup Job, basically what happends when you click on "create report".
But I can only find the last session
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: My Veeam Report v9.5.1

Post by veremin » 1 person likes this post

There are multiple examples on this forum how this can be achieved. So, feel free to search it through to find one that meets your expectations best (you can start with this report, for instance). Thanks!
Cragdoo
Veeam Vanguard
Posts: 628
Liked: 251 times
Joined: Sep 27, 2011 12:17 pm
Full Name: Craig Dalrymple
Location: Scotland
Contact:

Re: My Veeam Report v9.5.1

Post by Cragdoo » 1 person likes this post

Great script

FYI

If you're running from a server with just the VBR console installed you need to update line 46 to

Code: Select all

$veeamExePath = "C:\Program Files\Veeam\Backup and Replication\Console\Veeam.Backup.Shell.exe"
Cragdoo
Veeam Vanguard
Posts: 628
Liked: 251 times
Joined: Sep 27, 2011 12:17 pm
Full Name: Craig Dalrymple
Location: Scotland
Contact:

Re: My Veeam Report v9.5.1

Post by Cragdoo »

also confirmed ....works with Update4
Ollo
Enthusiast
Posts: 32
Liked: 3 times
Joined: Jan 19, 2018 6:32 am
Contact:

Re: My Veeam Report v9.5.1

Post by Ollo »

Hello, any update in near future? Didn't work with v10 anymore.
MiMaMo
Novice
Posts: 7
Liked: 4 times
Joined: Feb 27, 2020 3:04 pm
Full Name: Michael
Contact:

Re: My Veeam Report v9.5.1

Post by MiMaMo » 4 people like this post

I get the report running fine with V10! :-)

Just search for

Code: Select all

If ($VeeamVersion -lt 9.5) {
  Write-Host "Script requires VBR v9.5" -ForegroundColor Red
  Write-Host "Version detected - $VeeamVersion" -ForegroundColor Red
  exit
}
and change it to:

Code: Select all

If ($VeeamVersion -lt 10.0.0.4461) {
  Write-Host "Script requires VBR v10" -ForegroundColor Red
  Write-Host "Version detected - $VeeamVersion" -ForegroundColor Red
  exit
}
I know this is dirty but quick and work without any other change for me. :-)
albertwt
Veeam Legend
Posts: 879
Liked: 46 times
Joined: Nov 05, 2009 12:24 pm
Location: Sydney, NSW
Contact:

Re: My Veeam Report v9.5.1

Post by albertwt »

@MiMaMo,

Does the script completed correctly when running it against Veeam Backup & Replication 10.0.0.4461?
--
/* 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: My Veeam Report v9.5.1

Post by veremin »

It should as long as you change it in accordance with the Michael's suggestion. Thanks!
albertwt
Veeam Legend
Posts: 879
Liked: 46 times
Joined: Nov 05, 2009 12:24 pm
Location: Sydney, NSW
Contact:

Re: My Veeam Report v9.5.1

Post by albertwt »

OK, I got this warning, but all seems to be fine.

WARNING: This cmdlet is obsolete and no longer supported. To get computer backup job use "Get-VBRComputerBackupJob" instead.
--
/* Veeam software enthusiast user & supporter ! */
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: My Veeam Report v9.5.1

Post by oleg.feoktistov »

Hi,

Right, in v10 we introduced separate cmdlets for Agent Management Backup Jobs.
So, if you run Get-VBRJob over agent jobs, they are still retrieved but with such a warning.
Thus, I'd advise to use ComputerBackupJob cmdlets to simplify agent jobs management.
Yet, the report works fine agent-wise as long as you have all the necessary info obtained with Get-VBRJob.

Thanks,
Oleg
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: My Veeam Report v9.5.1

Post by veremin »

You can always suppress the warning by using WarningAction parameter in your script (set "SilentlyContinue" as its value). Thanks!
DavidL86
Influencer
Posts: 18
Liked: 2 times
Joined: Dec 21, 2018 5:12 pm
Full Name: David LETTIERI
Contact:

Re: My Veeam Report v9.5.1

Post by DavidL86 »

Hello Community,

Does anyone have been able to modify the script in order to include only VMs with a particular Tag ?

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

Re: My Veeam Report v9.5.1

Post by oleg.feoktistov »

Hi David,

Did you add your VMs to a job by tag object as a whole or just vm names?

Thanks,
Oleg
DavidL86
Influencer
Posts: 18
Liked: 2 times
Joined: Dec 21, 2018 5:12 pm
Full Name: David LETTIERI
Contact:

Re: My Veeam Report v9.5.1

Post by DavidL86 »

Hi Oleg,

All VMs backuped with Veeam have a tag named VEEAM, and an assigned tag to sort them. The VMs are then added to Jobs by assigned tag. I would like to filter on the Tag Category VEEAM directly.

Image

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

Re: My Veeam Report v9.5.1

Post by oleg.feoktistov »

Ok, David, if you added your vms to jobs by a tag as a whole (you included Tag object in Virtual Machines section of Backup Job Wizard and no VMs are listed under), on the step of jobs retrieval, as an example, you can modify the report in the following way:

Code: Select all

$jobs = Get-VBRJob
foreach ($job in $jobs) { 
$jobobject = Get-VBRJobObject -Job $job
if ($jobobject.Name -eq 'VEEAM') { #Where 'VEEAM' is a sample tag
   #Further actions on filtered job objects.
}} 
However, in that case, the tag is recognized as a single job object and the report will reflect info on that without any details on child vms.

If you only sorted your vms by tags but then added them as separate objects (you see VMs listed in Virtual Machines section of Backup Job Wizard), first you need to sort them by tag again using PowerCLI and then filter jobs by included objects with the names of VMs you just sorted:

Code: Select all

$connection = connect-viserver -server 'vCenterName' -Credential $creds
$tag = Get-Tag -Name 'VEEAM'
$vms = Get-VM -Tag $tag
$jobs = Get-VBRJob
foreach ($vm in $vms) {
    foreach ($job in $jobs) {
    $jobobject = Get-VBRJobObject -Job $job
    if ($jobobject.Name -eq $vm.Name) {
        #Further actions on filtered job objects.
}}} 
Kind regards,
Oleg
DavidL86
Influencer
Posts: 18
Liked: 2 times
Joined: Dec 21, 2018 5:12 pm
Full Name: David LETTIERI
Contact:

Re: My Veeam Report v9.5.1

Post by DavidL86 »

Hi Oleg,

Thanks for the time you're taking to answer me.

I added the code in the "Get all Backup/Backup Copy/Replica Jobs"

Code: Select all

# Get all Backup/Backup Copy/Replica Jobs
$allJobs = @()
If ($showSummaryBk + $showJobsBk + $showAllSessBk + $showAllTasksBk + $showRunningBk +
  $showRunningTasksBk + $showWarnFailBk + $showTaskWFBk + $showSuccessBk + $showTaskSuccessBk +
  $showSummaryRp + $showJobsRp + $showAllSessRp + $showAllTasksRp + $showRunningRp +
  $showRunningTasksRp + $showWarnFailRp + $showTaskWFRp + $showSuccessRp + $showTaskSuccessRp +
  $showSummaryBc + $showJobsBc + $showAllSessBc + $showAllTasksBc + $showIdleBc +
  $showPendingTasksBc + $showRunningBc + $showRunningTasksBc + $showWarnFailBc +
  $showTaskWFBc + $showSuccessBc + $showTaskSuccessBc) {
  $allJobs = Get-VBRJob
foreach ($job in $alljobs) { 
$jobobject = Get-VBRJobObject -Job $job
if ($jobobject.Name -eq 'VEEAM') { #Where 'VEEAM' is a sample tag
   #Further actions on filtered job objects.
Unfortunately I don't think it's working, because if I modify the tag name I have the same result.
Sorry I'm really not into PowerShell, do I miss something ?

Thanks a lot
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: My Veeam Report v9.5.1

Post by jhoughes »

That code will only run if your if statement returns a true result, and many of those variables are a default of false in Shawn’s script.

What is the purpose of trying to perform filtering with the if statement?
Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
DavidL86
Influencer
Posts: 18
Liked: 2 times
Joined: Dec 21, 2018 5:12 pm
Full Name: David LETTIERI
Contact:

Re: My Veeam Report v9.5.1

Post by DavidL86 »

Hi,
It seemed like the right place to insert the code Oleg provide to filter, but as I said my knowledge in Powershell in close to 0...
If you have a better idea I'm taking it :)
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: My Veeam Report v9.5.1

Post by oleg.feoktistov »

Hi David,

Could you, please, share the entire script you have?

Thanks,
Oleg
DavidL86
Influencer
Posts: 18
Liked: 2 times
Joined: Dec 21, 2018 5:12 pm
Full Name: David LETTIERI
Contact:

Re: My Veeam Report v9.5.1

Post by DavidL86 »

Hi,

Sure, but it is Shawn Masterson's and a bit long for the post, I couldn't paste all the script. Anyway I only modified few things at the beginning, it remains close to the original.

The part that I modified to try to filter VMs with tags is line 594 but apparently it wasn't a good idea

Thanks

Code: Select all

#requires -Version 3.0
<#

    .SYNOPSIS
    My Veeam Report is a flexible reporting script for Veeam Backup and
    Replication.

    .DESCRIPTION
    My Veeam Report is a flexible reporting script for Veeam Backup and
    Replication. This report can be customized to report on Backup, Replication,
    Backup Copy, Tape Backup, SureBackup and Agent Backup jobs as well as
    infrastructure details like repositories, proxies and license status. Work
    through the User Variables to determine what you would like to see and
    determine if you would like to save the results to a file or have them
    emailed to you.

    .EXAMPLE
    .\MyVeeamReport.ps1
    Run script from (an elevated) PowerShell console  
  
    .NOTES
    Author: Shawn Masterson
    Last Updated: December 2017
    Version: 9.5.3
  
    Requires:
    Veeam Backup & Replication v9.5 Update 3 (full or console install)
    VMware Infrastructure

#> 

#region User-Variables
# VBR Server (Server Name, FQDN or IP)
$vbrServer = "veeamServer"
# Report mode (RPO) - valid modes: any number of hours, Weekly or Monthly
# 24, 48, "Weekly", "Monthly"
$reportMode = 30
# Report Title
$rptTitle = "Backups Report"
# Show VBR Server name in report header
$showVBR = $true
# HTML Report Width (Percent)
$rptWidth = 97

# Location of Veeam executable (Veeam.Backup.Shell.exe)
$veeamExePath = "C:\Program Files\Veeam\Backup and Replication\Backup\Veeam.Backup.Shell.exe"

# Save HTML output to a file
$saveHTML = $true
# HTML File output path and filename
$pathHTML = "E:\Backup\MyVeeamReport_$(Get-Date -format MMddyyyy_hhmmss).htm"
# Launch HTML file after creation
$launchHTML = $false

# Email configuration
$sendEmail = $true
$emailHost = "mail.com"
$emailPort = 25
$emailEnableSSL = $false
$emailUser = ""
$emailPass = ""
$emailFrom = "VeeamBackup"
$emailToAddresses = @("david.lettieri@")
# Send HTML report as attachment (else HTML report is body)
$emailAttach = $false
# Email Subject 
$emailSubject = $rptTitle
# Append Report Mode to Email Subject E.g. My Veeam Report (Last 24 Hours)
$modeSubject = $true
# Append VBR Server name to Email Subject
$vbrSubject = $true
# Append Date and Time to Email Subject
$dtSubject = $false

# Show VM Backup Protection Summary (across entire infrastructure)
$showSummaryProtect = $true
# Show VMs with No Successful Backups within RPO ($reportMode)
$showUnprotectedVMs = $false
# Show VMs with Successful Backups within RPO ($reportMode)
# Also shows VMs with Only Backups with Warnings within RPO ($reportMode)
$showProtectedVMs = $false
# Exclude VMs from Missing and Successful Backups sections
# $excludevms = @("vm1","vm2","*_replica")
$excludeVMs = @("*_replica")
# Exclude VMs from Missing and Successful Backups sections in the following (vCenter) folder(s)
# $excludeFolder = @("folder1","folder2","*_testonly")
$excludeFolder = @("Replica","Templates")
# Exclude VMs from Missing and Successful Backups sections in the following (vCenter) datacenter(s)
# $excludeDC = @("dc1","dc2","dc*")
$excludeDC = @()
# Exclude Templates from Missing and Successful Backups sections
$excludeTemp = $true

# Show VMs Backed Up by Multiple Jobs within time frame ($reportMode)
$showMultiJobs = $false

# Show Backup Session Summary
$showSummaryBk = $true
# Show Backup Job Status
$showJobsBk = $true
# Show Backup Job Size (total)
$showBackupSizeBk = $true
# Show detailed information for Backup Jobs/Sessions (Avg Speed, Total(GB), Processed(GB), Read(GB), Transferred(GB), Dedupe, Compression)
$showDetailedBk = $true
# Show all Backup Sessions within time frame ($reportMode)
$showAllSessBk = $false
# Show all Backup Tasks from Sessions within time frame ($reportMode)
$showAllTasksBk = $true
# Show Running Backup Jobs
$showRunningBk = $true
# Show Running Backup Tasks
$showRunningTasksBk = $true
# Show Backup Sessions w/Warnings or Failures within time frame ($reportMode)
$showWarnFailBk = $true
# Show Backup Tasks w/Warnings or Failures from Sessions within time frame ($reportMode)
$showTaskWFBk = $true
# Show Successful Backup Sessions within time frame ($reportMode)
$showSuccessBk = $false
# Show Successful Backup Tasks from Sessions within time frame ($reportMode)
$showTaskSuccessBk = $false
# Only show last Session for each Backup Job
$onlyLastBk = $true
# Only report on the following Backup Job(s)
#$backupJob = @("Backup")

# Show Running Restore VM Sessions
$showRestoRunVM = $true
# Show Completed Restore VM Sessions within time frame ($reportMode)
$showRestoreVM = $false

# Show Replication Session Summary
$showSummaryRp = $true
# Show Replication Job Status
$showJobsRp = $false
# Show detailed information for Replication Jobs/Sessions (Avg Speed, Total(GB), Processed(GB), Read(GB), Transferred(GB), Dedupe, Compression)
$showDetailedRp = $true
# Show all Replication Sessions within time frame ($reportMode)
$showAllSessRp = $false
# Show all Replication Tasks from Sessions within time frame ($reportMode)
$showAllTasksRp = $false
# Show Running Replication Jobs
$showRunningRp = $false
# Show Running Replication Tasks
$showRunningTasksRp = $false
# Show Replication Sessions w/Warnings or Failures within time frame ($reportMode)
$showWarnFailRp = $false
# Show Replication Tasks w/Warnings or Failures from Sessions within time frame ($reportMode)
$showTaskWFRp = $false
# Show Successful Replication Sessions within time frame ($reportMode)
$showSuccessRp = $false
# Show Successful Replication Tasks from Sessions within time frame ($reportMode)
$showTaskSuccessRp = $false
# Only show last session for each Replication Job
$onlyLastRp = $false
# Only report on the following Replication Job(s)
#$replicaJob = @("Replica Job 1","Replica Job 3","Replica Job *")
#$replicaJob = @("")

# Show Backup Copy Session Summary
$showSummaryBc = $true
# Show Backup Copy Job Status
$showJobsBc = $false
# Show Backup Copy Job Size (total)
$showBackupSizeBc = $false
# Show detailed information for Backup Copy Sessions (Avg Speed, Total(GB), Processed(GB), Read(GB), Transferred(GB), Dedupe, Compression)
$showDetailedBc = $true
# Show all Backup Copy Sessions within time frame ($reportMode)
$showAllSessBc = $false
# Show all Backup Copy Tasks from Sessions within time frame ($reportMode)
$showAllTasksBc = $false
# Show Idle Backup Copy Sessions
$showIdleBc = $false
# Show Pending Backup Copy Tasks
$showPendingTasksBc = $false
# Show Working Backup Copy Jobs
$showRunningBc = $false
# Show Working Backup Copy Tasks
$showRunningTasksBc = $false
# Show Backup Copy Sessions w/Warnings or Failures within time frame ($reportMode)
$showWarnFailBc = $false
# Show Backup Copy Tasks w/Warnings or Failures from Sessions within time frame ($reportMode)
$showTaskWFBc = $false
# Show Successful Backup Copy Sessions within time frame ($reportMode)
$showSuccessBc = $false
# Show Successful Backup Copy Tasks from Sessions within time frame ($reportMode)
$showTaskSuccessBc = $false
# Only show last Session for each Backup Copy Job
$onlyLastBc = $false
# Only report on the following Backup Copy Job(s)
#$bcopyJob = @("Backup Copy Job 1","Backup Copy Job 3","Backup Copy Job *")
#$bcopyJob = @("")

# Show Tape Backup Session Summary
$showSummaryTp = $false
# Show Tape Backup Job Status
$showJobsTp = $false
# Show detailed information for Tape Backup Sessions (Avg Speed, Total(GB), Read(GB), Transferred(GB))
$showDetailedTp = $false
# Show all Tape Backup Sessions within time frame ($reportMode)
$showAllSessTp = $false
# Show all Tape Backup Tasks from Sessions within time frame ($reportMode)
$showAllTasksTp = $false
# Show Waiting Tape Backup Sessions
$showWaitingTp = $false
# Show Idle Tape Backup Sessions
$showIdleTp = $false
# Show Pending Tape Backup Tasks
$showPendingTasksTp = $false
# Show Working Tape Backup Jobs
$showRunningTp = $false
# Show Working Tape Backup Tasks
$showRunningTasksTp = $false
# Show Tape Backup Sessions w/Warnings or Failures within time frame ($reportMode)
$showWarnFailTp = $false
# Show Tape Backup Tasks w/Warnings or Failures from Sessions within time frame ($reportMode)
$showTaskWFTp = $false
# Show Successful Tape Backup Sessions within time frame ($reportMode)
$showSuccessTp = $false
# Show Successful Tape Backup Tasks from Sessions within time frame ($reportMode)
$showTaskSuccessTp = $false
# Only show last Session for each Tape Backup Job
$onlyLastTp = $false
# Only report on the following Tape Backup Job(s)
#$tapeJob = @("Tape Backup Job 1","Tape Backup Job 3","Tape Backup Job *")
#$tapeJob = @("")

# Show all Tapes
$showTapes = $false
# Show all Tapes by (Custom) Media Pool
$showTpMp = $false
# Show all Tapes by Vault
$showTpVlt = $false
# Show all Expired Tapes
$showExpTp = $false
# Show Expired Tapes by (Custom) Media Pool
$showExpTpMp = $false
# Show Expired Tapes by Vault
$showExpTpVlt = $false
# Show Tapes written to within time frame ($reportMode)
$showTpWrt = $false

# Show Agent Backup Session Summary
$showSummaryEp = $false
# Show Agent Backup Job Status
$showJobsEp = $false
# Show Agent Backup Job Size (total)
$showBackupSizeEp = $false
# Show all Agent Backup Sessions within time frame ($reportMode)
$showAllSessEp = $false
# Show Running Agent Backup jobs
$showRunningEp = $false
# Show Agent Backup Sessions w/Warnings or Failures within time frame ($reportMode)
$showWarnFailEp = $false
# Show Successful Agent Backup Sessions within time frame ($reportMode)
$showSuccessEp = $false
# Only show last session for each Agent Backup Job
$onlyLastEp = $false
# Only report on the following Agent Backup Job(s)
#$epbJob = @("Agent Backup Job 1","Agent Backup Job 3","Agent Backup Job *")
#$epbJob = @("")

# Show SureBackup Session Summary
$showSummarySb = $false
# Show SureBackup Job Status
$showJobsSb = $false
# Show all SureBackup Sessions within time frame ($reportMode)
$showAllSessSb = $false
# Show all SureBackup Tasks from Sessions within time frame ($reportMode)
$showAllTasksSb = $false
# Show Running SureBackup Jobs
$showRunningSb = $false
# Show Running SureBackup Tasks
$showRunningTasksSb = $false
# Show SureBackup Sessions w/Warnings or Failures within time frame ($reportMode)
$showWarnFailSb = $false
# Show SureBackup Tasks w/Warnings or Failures from Sessions within time frame ($reportMode)
$showTaskWFSb = $false
# Show Successful SureBackup Sessions within time frame ($reportMode)
$showSuccessSb = $false
# Show Successful SureBackup Tasks from Sessions within time frame ($reportMode)
$showTaskSuccessSb = $false
# Only show last Session for each SureBackup Job
$onlyLastSb = $false
# Only report on the following SureBackup Job(s)
#$surebJob = @("SureBackup Job 1","SureBackup Job 3","SureBackup Job *")
#$surebJob = @("")

# Show Configuration Backup Summary
$showSummaryConfig = $true
# Show Proxy Info
$showProxy = $true
# Show Repository Info
$showRepo = $true
# Show Repository Permissions for Agent Jobs
$showRepoPerms = $true
# Show Replica Target Info
$showReplicaTarget = $true
# Show Veeam Services Info (Windows Services)
$showServices = $true
# Show only Services that are NOT running
$hideRunningSvc = $true
# Show License expiry info
$showLicExp = $false

# Highlighting Thresholds
# Repository Free Space Remaining %
$repoCritical = 10
$repoWarn = 20
# Replica Target Free Space Remaining %
$replicaCritical = 10
$replicaWarn = 20
# License Days Remaining
$licenseCritical = 30
$licenseWarn = 90
#endregion
 
#region VersionInfo
$MVRversion = "9.5.3"
# Version 9.5.3 - SM
# Updated property changes introduced in VBR 9.5 Update 3

# Version 9.5.1.1 - SM
# Minor bug fixes:
# Removed requires VBR snapin
# Fixed HourstoCheck variable in Get-VMsBackupStatus function
# Version 9.5.1 - SM
# Updated HTML formatting - thanks for the inspiration Nick!
# Report header and email subject now reflect results (Failed/Warning/Success)
# Added report section - VMs Backed Up by Multiple Jobs within RPO
# Added report section - Repository Permissions for Agent Jobs
# Added Description field for Agent Job Status to identify type of Agent
# Added Next Run field for Agent Job Status (Fixed in VBR 9.5 Update 1)
# Added Next Run field for Configuration Backup Status (Fixed in VBR 9.5 Update 1)
# Added more details to VMs with No Successful/Successful/with Warnings within RPO
# Appended date and time to email attachment file name
# Added ability to append date and time to email subject
# Added ability to send email via SSL/TLS
# Renamed Endpoints to Agents
#
# Version 9.0.3 - SM
# Added report section - VM Backup Protection Summary (across entire infrastructure)
# Split report section - Split out VMs with only Backups with Warnings within RPO to separate from Successful
# Added report section - Backup Job Size (total)
# Added report section - All Backup Sessions
# Added report section - All Backup Tasks
# Added report section - Running Backup Tasks
# Added report section - Backup Tasks with Warnings or Failures
# Added report section - Successful Backup Tasks
# Added report section - Replication Job/Session Summary
# Added report section - Replication Job Status
# Added report section - All Replication Sessions
# Added report section - All Replication Tasks
# Added report section - Running Replication Jobs
# Added report section - Running Replication Tasks
# Added report section - Replication Job/Sessions with Warnings or Failures
# Added report section - Replication Tasks with Warnings or Failures
# Added report section - Successful Replication Jobs/Sessions
# Added report section - Successful Replication Tasks
# Added report section - Backup Copy Session Summary
# Added report section - Backup Copy Job Status
# Added report section - Backup Copy Job Size (total)
# Added report section - All Backup Copy Sessions
# Added report section - All Backup Copy Tasks
# Added report section - Idle Backup Copy Sessions
# Added report section - Pending Backup Copy Tasks
# Added report section - Working Backup Copy Jobs
# Added report section - Working Backup Copy Tasks
# Added report section - Backup Copy Sessions with Warnings or Failures
# Added report section - Backup Copy Tasks with Warnings or Failures
# Added report section - Successful Backup Copy Sessions
# Added report section - Successful Backup Copy Tasks
# Added report section - Tape Backup Session Summary
# Added report section - Tape Job Status
# Added report section - All Tape Backup Sessions
# Added report section - All Tape Backup Tasks
# Added report section - Waiting Tape Backup Sessions
# Added report section - Idle Tape Backup Sessions
# Added report section - Pending Tape Backup Tasks
# Added report section - Working Tape Backup Jobs
# Added report section - Working Tape Backup Tasks
# Added report section - Tape Backup Sessions with Warnings or Failures
# Added report section - Tape Backup Tasks with Warnings or Failures
# Added report section - Successful Tape Backup Sessions
# Added report section - Successful Tape Backup Tasks
# Added report section - All Tapes
# Added report section - All Tapes by (Custom) Media Pool
# Added report section - All Tapes by Vault
# Added report section - All Expired Tapes
# Added report section - Expired Tapes by (Custom) Media Pool - Thanks to Patrick IRVING & Olivier Dubroca!
# Added report section - Expired Tapes by Vault
# Added report section - All Tapes written to within time frame ($reportMode)
# Added report section - Endpoint Backup Job Size (total)
# Added report section - All Endpoint Backup Sessions
# Added report section - SureBackup Session Summary
# Added report section - SureBackup Job Status
# Added report section - All SureBackup Sessions
# Added report section - All SureBackup Tasks
# Added report section - Running SureBackup Jobs
# Added report section - Running SureBackup Tasks
# Added report section - SureBackup Sessions with Warnings or Failures
# Added report section - SureBackup Tasks with Warnings or Failures
# Added report section - Successful SureBackup Sessions
# Added report section - Successful SureBackup Tasks
# Added report section - Configuration Backup Status
# Added report section - Scale Out Repository Info - Thanks to Patrick IRVING & Olivier Dubroca!
# Added exclusion for Templates to VM Backup Protection sections
# Added Last Start and End times to VMs with Successful/Warning Backups
# Added Dedupe and Compression to Backup/Backup Copy/Replication session detailed info
# Added ability to report only on particular jobs (backup/replica/backup copy/tape/surebackup/endpoint)
# Added Mode/Type and Maximum Tasks to Proxy and Repository Info
# Filtered some heavy lifting commands to only run when/if needed
# Converted durations from Mins to HH:MM:SS
# Added html formatting of cells (vertical-align: middle;text-align:center;)
# Lots of misc tweaks/cleanup
#
# Version 9.0.2 - SM
# Fixed issue with Proxy details reported when using IP address instead of server names
# Fixed an issue where services were reported multiple times per server
#
# Version 9.0.1 - SM
# Initial version for VBR v9
# Updated version to follow VBR version (VeeamMajorVersion.VeeamMinorVersion.MVRVersion)
# Fixed Proxy Information (change in property names in v9)
# Rewrote Repository Info to use newly available properties (yay!)
# Updated Get-VMsBackupStatus to remove obsolete commandlet warning (Thanks tsightler!)
# Added ability to run from console only install
# Added ability to include VBR server in report title and email subject
# Rewrote License Info gathering to allow remote info gathering
# Misc minor tweaks/cleanup
#
# Version 2.0 - SM
# Misc minor tweaks/cleanup
# Proxy host IP info now always returns IPv4 address
# Added ability to query Veeam database for Repository size info
#   Big thanks to tsightler - http://forums.veeam.com/powershell-f26/get-vbrbackuprepository-why-no-size-info-t27296.html
# Added report section - Backup Job Status
# Added option to show detailed Backup Job/Session information (Avg Speed, Total(GB), Processed(GB), Read(GB), Transferred(GB))
# Added report section - Running VM Restore Sessions
# Added report section - Completed VM Restore Sessions
# Added report section - Endpoint Backup Results Summary
# Added report section - Endpoint Backup Job Status
# Added report section - Running Endpoint Backup Jobs
# Added report section - Endpoint Backup Jobs/Sessions with Warnings or Failures
# Added report section - Successful Endpoint Backup Jobs/Sessions
#
# Version 1.4.1 - SM
# Fixed issue with summary counts
# Version 1.4 - SM
# Misc minor tweaks/cleanup
# Added variable for report width
# Added variable for email subject
# Added ability to show/hide all report sections
# Added Protected/Unprotected VM Count to Summary
# Added per object details for sessions w/no details
# Added proxy host name to Proxy Details
# Added repository host name to Repository Details
# Added section showing successful sessions
# Added ability to view only last session per job
# Added Cluster field for protected/unprotected VMs
# Added catch for cifs repositories greater than 4TB as erroneous data is returned
# Added % Complete for Running Jobs
# Added ability to exclude multiple (vCenter) folders from Missing and Successful Backups section
# Added ability to exclude multiple (vCenter) datacenters from Missing and Successful Backups section
# Tweaked license info for better reporting across different date formats
#
# Version 1.3 - SM
# Now supports VBR v8
# For VBR v7, use report version 1.2
# Added more flexible options to save and launch file 
#
# Version 1.2 - SM
# Added option to show VMs Successfully backed up
#
# Version 1.1.4 - SM
# Misc tweaks/bug fixes
# Reconfigured HTML a bit to help with certain email clients
# Added cell coloring to highlight status
# Added $rptTitle variable to hold report title
# Added ability to send report via email as attachment
#
# Version 1.1.3 - SM
# Added Details to Sessions with Warnings or Failures
#
# Version 1.1.2 - SM
# Minor tweaks/updates
# Added Veeam version info to header
#
# Version 1.1.1 - Shawn Masterson
# Based on vPowerCLI v6 Army Report (v1.1) by Thomas McConnell
# http://www.vpowercli.co.uk/2012/01/23/vpowercli-v6-army-report/
# http://pastebin.com/6p3LrWt7
#
# Tweaked HTML header (color, title)
#
# Changed report width to 1024px
#
# Moved hard-coded path to exe/dll files to user declared variables ($veeamExePath/$veeamDllPath)
#
# Adjusted sorting on all objects
#
# Modified info group/counts
#   Modified - Total Jobs = Job Runs
#   Added - Read (GB)
#   Added - Transferred (GB)
#   Modified - Warning = Warnings
#   Modified - Failed = Failures
#   Added - Failed (last session)
#   Added - Running (currently running sessions)
# 
# Modified job lines
#   Renamed Header - Sessions with Warnings or Failures
#   Fixed Write (GB) - Broke with v7
#   
# Added support license renewal
#   Credit - Gavin Townsend  http://www.theagreeablecow.com/2012/09/sysadmin-modular-reporting-samreports.html
#   Original  Credit - Arne Fokkema  http://ict-freak.nl/2011/12/29/powershell-veeam-br-get-total-days-before-the-license-expires/
#
# Modified Proxy section
#   Removed Read/Write/Util - Broke in v7 - Workaround unknown
# 
# Modified Services section
#   Added - $runningSvc variable to toggle displaying services that are running
#   Added - Ability to hide section if no results returned (all services are running)
#   Added - Scans proxies and repositories as well as the VBR server for services
#
# Added VMs Not Backed Up section
#   Credit - Tom Sightler - http://sightunseen.org/blog/?p=1
#   http://www.sightunseen.org/files/vm_backup_status_dev.ps1
#   
# Modified $reportMode
#   Added ability to run with any number of hours (8,12,72 etc)
#   Added bits to allow for zero sessions (semi-gracefully)
#
# Added Running Jobs section
#   Added ability to toggle displaying running jobs
#
# Added catch to ensure running v7 or greater
#
#
# Version 1.1
# Added job lines as per a request on the website
#
# Version 1.0
# Clean up for release
#
# Version 0.9
# More cmdlet rewrite to improve perfomace, credit to @SethBartlett
# for practically writing the Get-vPCRepoInfo
#
# Version 0.8
# Added Read/Write stats for proxies at requests of @bsousapt
# Performance improvement of proxy tear down due to rewrite of cmdlet
# Replaced 2 other functions
# Added Warning counter, .00 to all storage returns and fetch credentials for
# remote WinLocal repos
#
# Version 0.7
# Added Utilisation(Get-vPCDailyProxyUsage) and Modes 24, 48, Weekly, and Monthly
# Minor performance tweaks 
#endregion

#region Connect
# Load Veeam Snapin
If (!(Get-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue)) {
  If (!(Add-PSSnapin -PassThru VeeamPSSnapIn)) {
    Write-Error "Unable to load Veeam snapin" -ForegroundColor Red
    Exit
  }
}

# Connect to VBR server
$OpenConnection = (Get-VBRServerSession).Server
If ($OpenConnection -ne $vbrServer){
  Disconnect-VBRServer
  Try {
    Connect-VBRServer -server $vbrServer -ErrorAction Stop
  } Catch {
    Write-Host "Unable to connect to VBR server - $vbrServer" -ForegroundColor Red
    exit
  }
}
#endregion

#region NonUser-Variables
# Get all Backup/Backup Copy/Replica Jobs
$allJobs = @()
If ($showSummaryBk + $showJobsBk + $showAllSessBk + $showAllTasksBk + $showRunningBk +
  $showRunningTasksBk + $showWarnFailBk + $showTaskWFBk + $showSuccessBk + $showTaskSuccessBk +
  $showSummaryRp + $showJobsRp + $showAllSessRp + $showAllTasksRp + $showRunningRp +
  $showRunningTasksRp + $showWarnFailRp + $showTaskWFRp + $showSuccessRp + $showTaskSuccessRp +
  $showSummaryBc + $showJobsBc + $showAllSessBc + $showAllTasksBc + $showIdleBc +
  $showPendingTasksBc + $showRunningBc + $showRunningTasksBc + $showWarnFailBc +
  $showTaskWFBc + $showSuccessBc + $showTaskSuccessBc) {
  $allJobs = Get-VBRJob
foreach ($job in $alljobs) { 
$jobobject = Get-VBRJobObject -Job $job
if ($jobobject.Name -eq 'VEEAM') { #Where 'VEEAM' is a sample tag
   #Further actions on filtered job objects.
}} 

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

Re: My Veeam Report v9.5.1

Post by oleg.feoktistov »

Gotcha. The part we inject our new loop into should look like that:

Code: Select all

#region NonUser-Variables
# Get all Backup/Backup Copy/Replica Jobs
$allJobs = @()
If ($showSummaryBk + $showJobsBk + $showAllSessBk + $showAllTasksBk + $showRunningBk +
  $showRunningTasksBk + $showWarnFailBk + $showTaskWFBk + $showSuccessBk + $showTaskSuccessBk +
  $showSummaryRp + $showJobsRp + $showAllSessRp + $showAllTasksRp + $showRunningRp +
  $showRunningTasksRp + $showWarnFailRp + $showTaskWFRp + $showSuccessRp + $showTaskSuccessRp +
  $showSummaryBc + $showJobsBc + $showAllSessBc + $showAllTasksBc + $showIdleBc +
  $showPendingTasksBc + $showRunningBc + $showRunningTasksBc + $showWarnFailBc +
  $showTaskWFBc + $showSuccessBc + $showTaskSuccessBc) {
  $jobs = Get-VBRJob
foreach ($job in $jobs) { 
$jobobject = Get-VBRJobObject -Job $job
if ($jobobject.Name -eq 'VEEAM') { #Where 'VEEAM' is a sample tag
   $allJobs += $job
}} 
So, basically, we need to:
- Query for all the jobs.
- Filter them with our job object name condition.
- Append each filtered job to $allJobs variable, which initially holds a null array.
Otherwise, if $job is not added to $allJobs array, the loop is rendered senseless.

This is the modification for Backup/Backup Copy/Replica Jobs only.
When it comes to other parts of Shawn's script like Backups, Agent Jobs and etc., as far as it goes, they would require separate amendments.

Kind regards,
Oleg
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: My Veeam Report v9.5.1

Post by jhoughes »

You should really also specify the object type as part of your criteria (the property is 'TypeDisplayName'), so that you are doing a match both by name and job object type.

Otherwise, if you query for a tag name which also matches for any of the other virtual entities (Hosts, Clusters, Datastores, VMs, or ResourcePools) used in any job, it would also end up in your "filtered" jobs list instead of only matching a tag.
Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: My Veeam Report v9.5.1

Post by oleg.feoktistov » 1 person likes this post

Joe is right, that part I missed:

Code: Select all

if ($jobobject.Name -eq 'VEEAM' -and $jobobject.TypeDisplayName -eq 'Tag') { #Where 'VEEAM' is a sample tag
   $allJobs += $job
}
@jhoughes, thanks!
DavidL86
Influencer
Posts: 18
Liked: 2 times
Joined: Dec 21, 2018 5:12 pm
Full Name: David LETTIERI
Contact:

Re: My Veeam Report v9.5.1

Post by DavidL86 »

Hi,
Thanks to both of you for the time you're taking to help me.

Seems that there's still something missing because I have the same result no matter the tag name I put, but I may have an idea.
Like I said earlier, the Tag Category is VEEAM, and then the assigned tag is something else. From Veeam point of view, the jobs are not using the General Category Tag (VEEAM), but the assigned one (XXX-XXX-W2K8 for example) in order to sort them and organize backups. Which means I don't seem "VEEAM" when editing a job, but the assigned tag (Red arrows)
So maybe it is not filtering at all because it can't find the tag VEEAM.
In that case how can I specify multiple assigned tags ? Good thing is that they all start with the same characters .

Thanks a lot

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

Re: My Veeam Report v9.5.1

Post by oleg.feoktistov »

Hi David,

Then you need to replace job object condition with the one below:

Code: Select all

if ($jobobject.Name -like 'server-*' -and $jobobject.TypeDisplayName -eq 'Tag') { #Where 'VEEAM' is a sample tag
   $allJobs += $job
}
Where 'server-*' is a maximum amount of common characters assigned tag names begin with, followed by wildcard symbol ( * ), which points to 0 or infinite amount of any other symbols after the pattern.
Make sure to replace it with your custom common characters.
The VMs are then added to Jobs by assigned tag. I would like to filter on the Tag Category VEEAM directly.
You most certainly can, but it would involve interacting with VMware through PowerCLI cmdlets to filter out tags by a tag category first
since tag as a job object type doesn't contain info on parent tag category.
So, if your tag names have common symbols and you can filter them with wildcard like in the method above, this step is ruled out.

Best wishes,
Oleg
spd2612
Novice
Posts: 3
Liked: never
Joined: Jun 18, 2020 3:58 pm
Full Name: John T Martin
Contact:

Re: My Veeam Report v9.5.1

Post by spd2612 »

I am running shawns script in veeam 10 but having a issue getting all the info I need for agent job managed by the server all it returns for the agent in Agent Backup Job Status is job name and description, I really need to see status, next run and result also
all my VM data is correct
Any ideas here what can be added to the script to get this ?
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests