Code: Select all
function Get-VBRGFSRetentionPolicy {
[CmdletBinding()]
param (
[Veeam.Backup.Core.CBackupJob[]]$Job
)
foreach ($item in $Job) {
if ($item.Options.GfsPolicy.IsEnabled -eq $true) {
$GFS = 'Enabled'
}
else {
$GFS = 'Disabled'
}
if ($item.Options.GFSPolicy.Weekly.IsEnabled -eq $true) {
$WeeklyRetention = 'Enabled'
}
else {
$WeeklyRetention = 'Disabled'
}
if ($item.Options.GFSPolicy.Monthly.IsEnabled -eq $true) {
$MonthlyRetention = 'Enabled'
}
else {
$MonthlyRetention = 'Disabled'
}
if ($item.Options.GFSPolicy.Yearly.IsEnabled -eq $true) {
$YearlyRetention = 'Enabled'
}
else {
$YearlyRetention = 'Disabled'
}
if ($WeeklyRetention -eq 'Enabled' -and $MonthlyRetention -eq 'Enabled' -and $YearlyRetention -eq 'Enabled') {
$item | select Name, @{n='Type';e={$_.TypeToString}}, @{n='State';e={$_.GetLastState()}}, `
@{n='GFS Policy';e={$GFS}}, @{n='WeeklyRetention';e={"$($_.Options.GFSPolicy.Weekly.KeepBackupsForNumberOfWeeks) Week(s)"}}, `
@{n='WeeklyDesiredTime';e={$_.Options.GFSPolicy.Weekly.DesiredTime}}, `
@{n='MonthlyRetention';e={"$($_.Options.GFSPolicy.Monthly.KeepBackupsForNumberOfMonths) Month(s)"}}, `
@{n='MonthlyDesiredTime';e={$_.Options.GFSPolicy.Monthly.DesiredTime}}, `
@{n='YearlyRetention';e={"$($_.Options.GFSPolicy.Yearly.KeepBackupsForNumberOfYears) Year(s)"}}, `
@{n='YearlyDesiredTime';e={$_.Options.GFSPolicy.Yearly.DesiredTime}}
}
elseif ($WeeklyRetention -eq 'Enabled' -and $MonthlyRetention -eq 'Enabled' -and $YearlyRetention -eq 'Disabled') {
$item | select Name, @{n='Type';e={$_.TypeToString}}, @{n='State';e={$_.GetLastState()}}, `
@{n='GFS Policy';e={$GFS}}, @{n='WeeklyRetention';e={"$($_.Options.GFSPolicy.Weekly.KeepBackupsForNumberOfWeeks) Week(s)"}}, `
@{n='WeeklyDesiredTime';e={$_.Options.GFSPolicy.Weekly.DesiredTime}}, `
@{n='MonthlyRetention';e={"$($_.Options.GFSPolicy.Monthly.KeepBackupsForNumberOfMonths) Month(s)"}}, `
@{n='MonthlyDesiredTime';e={$_.Options.GFSPolicy.Monthly.DesiredTime}}, `
@{n='YearlyRetention';e={""}}, `
@{n='YearlyDesiredTime';e={""}}
}
elseif ($WeeklyRetention -eq 'Enabled' -and $MonthlyRetention -eq 'Disabled' -and $YearlyRetention -eq 'Disabled') {
$item | select Name, @{n='Type';e={$_.TypeToString}}, @{n='State';e={$_.GetLastState()}}, `
@{n='GFS Policy';e={$GFS}}, @{n='WeeklyRetention';e={"$($_.Options.GFSPolicy.Weekly.KeepBackupsForNumberOfWeeks) Week(s)"}}, `
@{n='WeeklyDesiredTime';e={$_.Options.GFSPolicy.Weekly.DesiredTime}}, `
@{n='MonthlyRetention';e={""}}, `
@{n='MonthlyDesiredTime';e={""}}, `
@{n='YearlyRetention';e={""}}, `
@{n='YearlyDesiredTime';e={""}}
}
elseif ($WeeklyRetention -eq 'Enabled' -and $MonthlyRetention -eq 'Disabled' -and $YearlyRetention -eq 'Enabled') {
$item | select Name, @{n='Type';e={$_.TypeToString}}, @{n='State';e={$_.GetLastState()}}, `
@{n='GFS Policy';e={$GFS}}, @{n='WeeklyRetention';e={"$($_.Options.GFSPolicy.Weekly.KeepBackupsForNumberOfWeeks) Week(s)"}}, `
@{n='WeeklyDesiredTime';e={$_.Options.GFSPolicy.Weekly.DesiredTime}}, `
@{n='MonthlyRetention';e={""}}, `
@{n='MonthlyDesiredTime';e={""}}, `
@{n='YearlyRetention';e={"$($_.Options.GFSPolicy.Yearly.KeepBackupsForNumberOfYears) Year(s)"}}, `
@{n='YearlyDesiredTime';e={$_.Options.GFSPolicy.Yearly.DesiredTime}}
}
elseif ($WeeklyRetention -eq 'Disabled' -and $MonthlyRetention -eq 'Enabled' -and $YearlyRetention -eq 'Enabled') {
$item | select Name, @{n='Type';e={$_.TypeToString}}, @{n='State';e={$_.GetLastState()}}, `
@{n='GFS Policy';e={$GFS}}, @{n='WeeklyRetention';e={""}}, `
@{n='WeeklyDesiredTime';e={""}}, `
@{n='MonthlyRetention';e={"$($_.Options.GFSPolicy.Monthly.KeepBackupsForNumberOfMonths) Month(s)"}}, `
@{n='MonthlyDesiredTime';e={$_.Options.GFSPolicy.Monthly.DesiredTime}}, `
@{n='YearlyRetention';e={"$($_.Options.GFSPolicy.Yearly.KeepBackupsForNumberOfYears) Year(s)"}}, `
@{n='YearlyDesiredTime';e={$_.Options.GFSPolicy.Yearly.DesiredTime}}
}
elseif ($WeeklyRetention -eq 'Disabled' -and $MonthlyRetention -eq 'Enabled' -and $YearlyRetention -eq 'Disabled') {
$item | select Name, @{n='Type';e={$_.TypeToString}}, @{n='State';e={$_.GetLastState()}}, `
@{n='GFS Policy';e={$GFS}}, @{n='WeeklyRetention';e={""}}, `
@{n='WeeklyDesiredTime';e={""}}, `
@{n='MonthlyRetention';e={"$($_.Options.GFSPolicy.Monthly.KeepBackupsForNumberOfMonths) Month(s)"}}, `
@{n='MonthlyDesiredTime';e={$_.Options.GFSPolicy.Monthly.DesiredTime}}, `
@{n='YearlyRetention';e={""}}, `
@{n='YearlyDesiredTime';e={""}}
}
elseif ($WeeklyRetention -eq 'Disabled' -and $MonthlyRetention -eq 'Disabled' -and $YearlyRetention -eq 'Enabled') {
$item | select Name, @{n='Type';e={$_.TypeToString}}, @{n='State';e={$_.GetLastState()}}, `
@{n='GFS Policy';e={$GFS}}, @{n='WeeklyRetention';e={""}}, `
@{n='WeeklyDesiredTime';e={""}}, `
@{n='MonthlyRetention';e={""}}, `
@{n='MonthlyDesiredTime';e={""}}, `
@{n='YearlyRetention';e={$_.Options.GFSPolicy.Yearly.KeepBackupsForNumberOfYears}}, `
@{n='YearlyDesiredTime';e={$_.Options.GFSPolicy.Yearly.DesiredTime}}
}
else {
$item | select Name, @{n='Type';e={$_.TypeToString}}, @{n='State';e={$_.GetLastState()}}, `
@{n='GFS Policy';e={$GFS}}, @{n='WeeklyRetention';e={""}}, `
@{n='WeeklyDesiredTime';e={""}}, `
@{n='MonthlyRetention';e={""}}, `
@{n='MonthlyDesiredTime';e={""}}, `
@{n='YearlyRetention';e={""}}, `
@{n='YearlyDesiredTime';e={""}}
}
}
}
Code: Select all
$job = Get-VBRJob
$retention = Get-VBRGFSRetentionPolicy -Job $job