Src/Private/Get-AbrVbrBackupjob.ps1
function Get-AbrVbrBackupjob { <# .SYNOPSIS Used by As Built Report to returns backup jobs created in Veeam Backup & Replication. .DESCRIPTION Documents the configuration of Veeam VBR in Word/HTML/Text formats using PScribo. .NOTES Version: 0.4.0 Author: Jonathan Colon Twitter: @jcolonfzenpr Github: rebelinux Credits: Iain Brighton (@iainbrighton) - PScribo module .LINK https://github.com/AsBuiltReport/AsBuiltReport.Veeam.VBR #> [CmdletBinding()] param ( ) begin { Write-PscriboMessage "Discovering Veeam VBR Backup jobs information from $System." } process { try { if ((Get-VBRJob -WarningAction SilentlyContinue).count -gt 0) { Section -Style Heading3 'Backup Jobs' { Paragraph "The following section list backup jobs created in Veeam Backup & Replication." BlankLine $OutObj = @() if ((Get-VBRServerSession).Server) { $Bkjobs = Get-VBRJob -WarningAction SilentlyContinue | Where-object {$_.TypeToString -ne 'Windows Agent Backup'} foreach ($Bkjob in $Bkjobs) { try { Write-PscriboMessage "Discovered $($Bkjob.Name) backup job." $inObj = [ordered] @{ 'Name' = $Bkjob.Name 'Type' = $Bkjob.TypeToString 'Status' = Switch ($Bkjob.IsScheduleEnabled) { 'False' {'Disabled'} 'True' {'Enabled'} } 'Latest Result' = $Bkjob.info.LatestStatus 'Target Repository' = Switch ($Bkjob.info.TargetRepositoryId) { '00000000-0000-0000-0000-000000000000' {$Bkjob.TargetDir} {$Null -eq (Get-VBRBackupRepository | Where-Object {$_.Id -eq $Bkjob.info.TargetRepositoryId}).Name} {(Get-VBRBackupRepository -ScaleOut | Where-Object {$_.Id -eq $Bkjob.info.TargetRepositoryId}).Name} default {(Get-VBRBackupRepository | Where-Object {$_.Id -eq $Bkjob.info.TargetRepositoryId}).Name} } } $OutObj += [pscustomobject]$inobj } catch { Write-PscriboMessage -IsWarning $_.Exception.Message } } $TableParams = @{ Name = "Backup Jobs - $(((Get-VBRServerSession).Server).ToString().ToUpper().Split(".")[0])" List = $false ColumnWidths = 25, 20, 15, 15, 25 } if ($Report.ShowTableCaptions) { $TableParams['Caption'] = "- $($TableParams.Name)" } $OutObj | Sort-Object -Property Name |Table @TableParams } } } } catch { Write-PscriboMessage -IsWarning $_.Exception.Message } } end {} } |