-
Notifications
You must be signed in to change notification settings - Fork 200
/
Copy pathSet-ExResourceProperties.ps1
130 lines (110 loc) · 5.11 KB
/
Set-ExResourceProperties.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#Requires -Version 5.0
<#
.SYNOPSIS
Connect to Microsoft Exchange Server and sets the resource properties
.DESCRIPTION
.NOTES
This PowerShell script was developed and optimized for ScriptRunner. The use of the scripts requires ScriptRunner.
The customer or user is authorized to copy the script from the repository and use them in ScriptRunner.
The terms of use for ScriptRunner do not apply to this script. In particular, ScriptRunner Software GmbH assumes no liability for the function,
the use and the consequences of the use of this freely available script.
PowerShell is a product of Microsoft Corporation. ScriptRunner is a product of ScriptRunner Software GmbH.
© ScriptRunner Software GmbH
.COMPONENT
.LINK
https://github.com/scriptrunner/ActionPacks/tree/master/Exchange/Resources
.Parameter MailboxId
[sr-en] Alias, Display name, Distinguished name, SamAccountName, Guid or user principal name of the resource from which to set properties
.Parameter AccountDisabled
[sr-en] Disable the account that's associated with the resource
.Parameter Alias
[sr-en] Alias name of the resource
.Parameter DisplayName
[sr-en] Display name of the resource
.Parameter ResourceCapacity
[sr-en] Capacity of the resource
.Parameter AllBookInPolicy
[sr-en] Automatically approve in-policy requests from all users
.Parameter AllowRecurringMeetings
[sr-en] Allow recurring meetings
.Parameter BookingWindowInDays
[sr-en] Maximum number of days in advance that the resource can be reserved
.Parameter EnforceSchedulingHorizon
[sr-en] Behavior of recurring meetings that extend beyond the date specified by the BookingWindowInDays parameter
.Parameter MaximumDurationInMinutes
[sr-en] Duration in minutes for meeting requests
.Parameter ScheduleOnlyDuringWorkHours
[sr-en] Allow meetings to be scheduled outside of the working hours that are defined for the resource
#>
param(
[Parameter(Mandatory = $true)]
[string]$MailboxId,
[switch]$AccountDisabled,
[string]$Alias,
[string]$DisplayName,
[int]$ResourceCapacity,
[bool]$AllBookInPolicy ,
[bool]$AllowRecurringMeetings,
[int]$BookingWindowInDays,
[bool]$EnforceSchedulingHorizon,
[int]$MaximumDurationInMinutes,
[bool]$ScheduleOnlyDuringWorkHours
)
try{
$box = Get-Mailbox -Identity $MailboxId | Select-Object Name,AccountDisabled
if($null -ne $box){
if($PSBoundParameters.ContainsKey('Alias')){
Set-Mailbox -Identity $box.Name -Alias $Alias
}
if($PSBoundParameters.ContainsKey('DisplayName')){
Set-Mailbox -Identity $box.Name -DisplayName $DisplayName
}
if($PSBoundParameters.ContainsKey('ResourceCapacity') -eq $true ){
Set-Mailbox -Identity $box.Name -ResourceCapacity $ResourceCapacity
}
if($PSBoundParameters.ContainsKey('AllBookInPolicy') -eq $true ){
Set-CalendarProcessing -Identity $box.Name -AllBookInPolicy $AllBookInPolicy
}
if($PSBoundParameters.ContainsKey('AllowRecurringMeetings') -eq $true ){
Set-CalendarProcessing -Identity $box.Name -AllowRecurringMeetings $AllowRecurringMeetings
}
if($PSBoundParameters.ContainsKey('BookingWindowInDays') -eq $true ){
Set-CalendarProcessing -Identity $box.Name -BookingWindowInDays $BookingWindowInDays
}
if($PSBoundParameters.ContainsKey('EnforceSchedulingHorizon') -eq $true ){
Set-CalendarProcessing -Identity $box.Name -EnforceSchedulingHorizon $EnforceSchedulingHorizon
}
if($PSBoundParameters.ContainsKey('MaximumDurationInMinutes') -eq $true ){
Set-CalendarProcessing -Identity $box.Name -MaximumDurationInMinutes $MaximumDurationInMinutes
}
if($PSBoundParameters.ContainsKey('ScheduleOnlyDuringWorkHours') -eq $true ){
Set-CalendarProcessing -Identity $box.Name -ScheduleOnlyDuringWorkHours $ScheduleOnlyDuringWorkHours
}
if($PSBoundParameters.ContainsKey('AccountDisabled') -ne $true){
$AccountDisabled = $box.AccountDisabled
}
Set-Mailbox -Identity $box.Name -AccountDisabled:$AccountDisabled -Confirm:$false
$resultMessage = @()
$resultMessage += Get-Mailbox -Identity $box.Name | `
Select-Object AccountDisabled,Alias,DisplayName,ResourceCapacity,WindowsEmailAddress
$resultMessage += Get-CalendarProcessing -Identity $box.Name | `
Select-Object AllBookInPolicy,AllowRecurringMeetings,BookingWindowInDays,EnforceSchedulingHorizon,MaximumDurationInMinutes,ScheduleOnlyDuringWorkHours
if($SRXEnv) {
$SRXEnv.ResultMessage = $resultMessage
}
else{
Write-Output $resultMessage
}
}
else{
if($SRXEnv) {
$SRXEnv.ResultMessage = "Resource $($MailboxId) not found"
}
Throw "Resource $($MailboxId) not found"
}
}
catch{
throw
}
finally{
}