PowerShell script exchange
Post Reply
efd121
Enthusiast
Posts: 49
Liked: 2 times
Joined: Aug 07, 2015 8:45 pm
Full Name: David Engler
Contact:

Set tape job to third sunday

Post by efd121 »

I'm having trouble setting a new tape job to run on specific day of the month. In this example I want the job to run on the third Sunday
When the job is created it schedules it for daily at 1:23 and when I change it to monthly at this time the only settings i see changed are OptionsDaily.Enabled changes from True to False and the OptionsMonthly.Enabled changes from False to True
I tried using the code below to make the same changes but the job is still scheduled to run daily.
Can anyone point me in the right direction?
Dave

Code: Select all

$Weekend = "Third"
$DayToRun = "Sunday"
$MonthlyOptions = New-VBRMonthlyOptions -DayNumberInMonth $Weekend -DayOfWeek $DayToRun -Period 1:23
$SchedOptions = New-VBRBackupToTapeScheduleOptions -Type Monthly -MonthlyOptions $MonthlyOptions -Enabled

$Options = Get-VBRJobScheduleOptions -Job $TapeJob
$Options.OptionsDaily.Enabled = $false
$Options.OptionsMonthly.Enabled = $true

Set-VBRJobScheduleOptions -Options $Options -Job $TapeJob
veremin
Product Manager
Posts: 20283
Liked: 2258 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Set tape job to third sunday

Post by veremin »

Try the following script and see whether it meets your expectations:

Code: Select all

$TapeJob = Get-VBRTapeJob -Name "Name of your backup to tape job"
$MonthlyOptions = New-VBRMonthlyOptions -DayOfWeek Sunday -DayNumberInMonth Third 
$ScheduleOptions = New-VBRBackupToTapeScheduleOptions -Type Monthly -MonthlyOptions $MonthlyOptions -Enabled
Set-VBRBackupToTapeJob -ScheduleOptions $ScheduleOptions -Job $TapeJob
Thanks.
efd121
Enthusiast
Posts: 49
Liked: 2 times
Joined: Aug 07, 2015 8:45 pm
Full Name: David Engler
Contact:

Re: Set tape job to third sunday

Post by efd121 »

Thanks I will give it a try next week when I'm back in the office
Dave
veremin
Product Manager
Posts: 20283
Liked: 2258 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Set tape job to third sunday

Post by veremin »

Ok, kindly, keep me updated. Thanks.
efd121
Enthusiast
Posts: 49
Liked: 2 times
Joined: Aug 07, 2015 8:45 pm
Full Name: David Engler
Contact:

Re: Set tape job to third sunday

Post by efd121 »

I was able to update my script based on your input and its working as expected. Thanks for the help.
Dave
veremin
Product Manager
Posts: 20283
Liked: 2258 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Set tape job to third sunday

Post by veremin »

You're welcome. Glad to know that my input was helpful. If other questions arise, let me know.
Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests