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

Set tape job to third sunday

Post by efd121 » Jun 29, 2017 9:02 pm

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: 17078
Liked: 1475 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Set tape job to third sunday

Post by veremin » Jun 30, 2017 8:38 am

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: 30
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 » Jun 30, 2017 12:31 pm

Thanks I will give it a try next week when I'm back in the office
Dave

veremin
Product Manager
Posts: 17078
Liked: 1475 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Set tape job to third sunday

Post by veremin » Jun 30, 2017 12:53 pm

Ok, kindly, keep me updated. Thanks.

efd121
Enthusiast
Posts: 30
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 » Jul 05, 2017 2:56 pm

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: 17078
Liked: 1475 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Set tape job to third sunday

Post by veremin » Jul 05, 2017 2:57 pm

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 5 guests