Script to set retention on copy jobs

PowerShell script exchange

Script to set retention on copy jobs

Veeam Logoby RichardA » Wed Oct 05, 2016 10:12 am


I wish to change the retention period on all my copy jobs. I have the PoweShell code working on a single job:

Code: Select all
asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Copy Job One"
$Options = $Job.GetOptions()
$Options.GenerationPolicy.RetentionPolicyType = "GFS"
$Options.GenerationPolicy.GFSWeeklyBackups = 4
$Options.GenerationPolicy.GFSMonthlyBackups = 0
$Options.GenerationPolicy.GFSQuarterlyBackups = 0
$Options.GenerationPolicy.GFSYearlyBackups = 0

I now wish to run these commands against a list copy job names I have in a text file called CopyJobs.txt. I am a bit of a PowerShell newbie and having trouble getting this working, any help to apply the above commands to a list of jobs in a text file would be greatly appreciated.

Posts: 1
Liked: never
Joined: Wed Oct 05, 2016 9:39 am
Full Name: Richard Arnold

Re: Script to set retention on copy jobs

Veeam Logoby tdewin » Wed Oct 05, 2016 12:31 pm

hopefully this can help you started

Code: Select all
asnp veeampssnapin
Get-Content .\job.txt | foreach {
 $jobname = $_;
 $job = get-vbrjob -name $jobname

in job.txt, every line is just a jobname
Veeam Software
Posts: 1185
Liked: 406 times
Joined: Fri Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin

Return to PowerShell

Who is online

Users browsing this forum: No registered users and 1 guest