-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGet-MailboxCalendarDelegates.ps1
72 lines (69 loc) · 4.83 KB
/
Get-MailboxCalendarDelegates.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
function Get-MailboxCalendarDelegates {
<#
.SYNOPSIS
Retrieves a list of user delegated calendar permissions.
.DESCRIPTION
Retrieves a list of user delegated calendar permissions.
.PARAMETER MailboxNames
Array of mailbox names in string format.
.PARAMETER MailboxObject
One or more mailbox objects.
.LINK
http://www.the-little-things.net
.LINK
https://github.com/zloeber/Powershell/
.NOTES
Last edit : 10/10/2014
Version : 1.0.0 10/10/2014
Author : Zachary Loeber
.EXAMPLE
Get-MailboxCalendarDelegates -MailboxName "Test User1" -Verbose
Description
-----------
TBD
#>
[CmdLetBinding(DefaultParameterSetName='AsStringArray')]
param(
[Parameter(ParameterSetName='AsStringArray', Mandatory=$True, ValueFromPipeline=$True, Position=0, HelpMessage="Enter an Exchange mailbox name")]
[string[]]$MailboxNames,
[Parameter(ParameterSetName='AsMailbox', Mandatory=$True, ValueFromPipeline=$True, Position=0, HelpMessage="Enter an Exchange mailbox name")]
$MailboxObject
)
begin {
Write-Verbose "$($MyInvocation.MyCommand): Begin"
$Mailboxes = @()
}
process {
switch ($PSCmdlet.ParameterSetName) {
'AsStringArray' {
try {
$Mailboxes = @($MailboxNames | Foreach {Get-Mailbox $_ -erroraction Stop})
}
catch {
Write-Warning = "$($MyInvocation.MyCommand): $_.Exception.Message"
}
}
'AsMailbox' {
$Mailboxes = @($MailboxObject)
}
}
foreach ($Mailbox in $Mailboxes) {
Write-Verbose "$($MyInvocation.MyCommand): Processing Mailbox $($Mailbox.Name)"
$PossibleDelegates = @(Get-CalendarProcessing $Mailbox | Where {($_.resourcedelegates)})
$PossibleDelegates | Foreach {
$delegates = @()
Foreach ($delegate in $_.resourcedelegates)
{
$delegates += $delegate.Name
}
New-Object psobject -Property @{
'Mailbox' = $Mailbox.Name
'Delegates' = $delegates
}
}
}
}
end {
Write-Verbose "$($MyInvocation.MyCommand): End"
}
}