Set-VeeamBackupWindowOptions.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74


<#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
}
}