Skip to content

Commit d5faa63

Browse files
Mailbox Query
1 parent 6b40920 commit d5faa63

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#Requires -Version 5.0
2+
3+
<#
4+
.SYNOPSIS
5+
Connect to Microsoft Exchange Server and gets the mailboxes
6+
7+
.DESCRIPTION
8+
9+
.NOTES
10+
This PowerShell script was developed and optimized for ScriptRunner. The use of the scripts requires ScriptRunner.
11+
The customer or user is authorized to copy the script from the repository and use them in ScriptRunner.
12+
The terms of use for ScriptRunner do not apply to this script. In particular, ScriptRunner Software GmbH assumes no liability for the function,
13+
the use and the consequences of the use of this freely available script.
14+
PowerShell is a product of Microsoft Corporation. ScriptRunner is a product of ScriptRunner Software GmbH.
15+
© ScriptRunner Software GmbH
16+
17+
.COMPONENT
18+
19+
.LINK
20+
https://github.com/scriptrunner/ActionPacks/tree/master/Exchange/_QUERY_
21+
#>
22+
23+
param(
24+
)
25+
26+
try{
27+
[string[]]$Properties = @('ArchiveStatus','UserPrincipalName','DisplayName','WindowsEmailAddress','IsMailboxEnabled','IsResource','PrimarySmtpAddress')
28+
$boxes = Get-Mailbox -SortBy DisplayName | Select-Object $Properties
29+
30+
foreach($box in $boxes){
31+
if($null -ne $SRXEnv) {
32+
$null = $SRXEnv.ResultList.Add($box.PrimarySmtpAddress) # Value
33+
$null = $SRXEnv.ResultList2.Add("$($box.DisplayName) ($($box.PrimarySmtpAddress)") # DisplayValue
34+
}
35+
else{
36+
Write-Output $box.PrimarySmtpAddress
37+
}
38+
}
39+
}
40+
catch{
41+
throw
42+
}
43+
finally{
44+
}

0 commit comments

Comments
 (0)