Set-VeeamBackupWindowOptions.ps1



<#PSScriptInfo
 
.VERSION 1.0
 
.GUID e46a8332-2356-4667-9c11-8a3cd4668940
 
.AUTHOR saw-friendship
 
.COMPANYNAME
 
.COPYRIGHT
 
.TAGS saw-friendship Veeam Backup WindowOptions
 
.LICENSEURI
 
.PROJECTURI
 
.ICONURI
 
.EXTERNALMODULEDEPENDENCIES
 
.REQUIREDSCRIPTS
 
.EXTERNALSCRIPTDEPENDENCIES
 
.RELEASENOTES
 
 
#>


<#
 
.DESCRIPTION
 Set-VeeamBackupWindowOptions
 
.EXAMPLE
 Get-VBRJob | Set-VeeamBackupWindowOptions
   
.EXAMPLE
 Set-VeeamBackupWindowOptions -BackupJob (Get-VBRJob -Name 'Server')
    
.EXAMPLE
 Get-VBRJob -Name 'Server' | Set-VeeamBackupWindowOptions
   
.EXAMPLE
 Get-VBRJob -Name 'Server' | Set-VeeamBackupWindowOptions -FromHour 9 -ToHour 21 -Enabled $false
   
 
#>
 


param(
[parameter(Mandatory=$true,ValueFromPipeline=$true,HelpMessage='Use pipeline after Get-VBRJob')][Veeam.Backup.Core.CBackupJob[]]$BackupJob,
[parameter(HelpMessage='Monday Range Sunday-Saturday')][ValidateSet('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday')][string]$FromDay = 'Sunday',
[ValidateRange(0,23)][int]$FromHour = 0,
[parameter(HelpMessage='Monday Range Sunday-Saturday')][ValidateSet('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday')][string]$ToDay = 'Saturday',
[ValidateRange(0,23)][int]$ToHour = 23,
[bool]$Enabled = $True
)

Process{
    Foreach ($Job in $BackupJob) {
        $ScheduleOptions = Get-VBRJobScheduleOptions -Job $Job
        $ScheduleOptions.OptionsBackupWindow = New-VBRBackupWindowOptions -FromDay $FromDay -FromHour $FromHour -ToDay $ToDay -ToHour $ToHour -Enabled:$Enabled
        Set-VBRJobScheduleOptions -Job $Job -Options $ScheduleOptions
    }    
}