There is a similar post from 2016 however i am having issues converting it to do what I need and am hoping you can help.
On the advanced settings under "Target" on a backup copy i need to Enable Storage-level Corruption guard, ticket the box that says " Perform backup files heath check" and set this to Last Saturday of the month
AND
Full Backup File Maintenance and tick "Remove deleted Items data after "30 days" and Defragment and compact full backup file to the last Sunday of the month.
This needs to be done based on a "foreach" bases based on backup copy name i have in a csv.
The original code looks like this:
Code: Select all
$days=@("Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday")
$weeks=@("First", "Second", "Third", "Fourth", "Last")
$d=0
$w=0
$jobs= get-vbrjob | ? {$_.JobType -eq "Backup"} | sort Name
foreach ($job in $jobs) {
write-host $job.Name $days[$d] $weeks[$w]
$Options=$job.getoptions()
$Options.GenerationPolicy.RecheckScheduleKind = "Monthly"
$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = $days[$d]
$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = $weeks[$w]
$Options.GenerationPolicy.EnableRechek = $true
$job.SetOptions($Options) | out-null
$d++
if ($d -ge $days.count) { $d = 0 ; $w++ }
if ($w -ge $weeks.count) { $w = 0 }
}
im not 100% sure it would do the second bit but i do believe it should be able to do "Full Backup File Maintenance and tick "Remove deleted Items data after "30 days" and Defragment and compact full backup file to the last Sunday of the month."
i have changed this to:
Code: Select all
$days=@("Saturday")
$weeks=@("Last")
$jobs= import-csv C:\script\test.csv
foreach ($i in $jobs) {
#write-host $job.bc-name $days $weeks
$Options=$job.getoptions()
$Options.GenerationPolicy.RecheckScheduleKind = "Monthly"
$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = $days
$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = $weeks
$Options.GenerationPolicy.EnableRechek = $true
$job.SetOptions($Options) | out-null
$d++
if ($d -ge $days.count) { $d = 0 ; $w++ }
if ($w -ge $weeks.count) { $w = 0 }
}
Code: Select all
Cannot find an overload for "SetOptions" and the argument count: "1".
At line:16 char:3
+ $job.SetOptions($Options) | out-null
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
any ideas - if it need to be totally redone then so bit it
thanks in advance