PowerShell script exchange
Post Reply
RichardA
Lurker
Posts: 1
Liked: never
Joined: Oct 05, 2016 9:39 am
Full Name: Richard Arnold
Contact:

Script to set retention on copy jobs

Post by RichardA »

Hi

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 
$Job.SetOptions($Options)
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.

Thanks!
tdewin
Veeam Software
Posts: 1818
Liked: 655 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: Script to set retention on copy jobs

Post by tdewin »

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
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests