-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGet-xInboxRule.ps1
More file actions
27 lines (23 loc) · 1.02 KB
/
Get-xInboxRule.ps1
File metadata and controls
27 lines (23 loc) · 1.02 KB
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
function Get-xInboxRule {
param
(
[Parameter(Mandatory,ValueFromPipeline,ValueFromPipelineByPropertyName)]
$Mailbox,
[Parameter(Mandatory)]
[System.Management.Automation.CredentialAttribute()]
[pscredential]
$Credential
)
begin {
Import-Module 'C:\Program Files\Microsoft\Exchange\Web Services\2.2\Microsoft.Exchange.WebServices.dll'
}
process {
$ExchangeService = [Microsoft.Exchange.WebServices.Data.ExchangeService]::new([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2013)
$ExchangeService.Credentials = [System.Net.NetworkCredential]::new($Credential.UserName,$Credential.Password)
$ExchangeService.ImpersonatedUserId = [Microsoft.Exchange.WebServices.Data.ImpersonatedUserId]::new([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SmtpAddress,$Mailbox)
$ExchangeService.Url = "https://outlook.office365.com/EWS/Exchange.asmx"
$ExchangeService.GetInboxRules()
}
end {
}
}