-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGet-xCalendarInformation.ps1
More file actions
31 lines (26 loc) · 1.33 KB
/
Get-xCalendarInformation.ps1
File metadata and controls
31 lines (26 loc) · 1.33 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
28
29
30
31
function Get-xCalendarInformation {
[outputtype('Microsoft.Exchange.WebServices.Data.Item')]
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()
$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"
$CalendarFolder = [Microsoft.Exchange.WebServices.Data.CalendarFolder]::Bind($ExchangeService,[Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar)
$View = [Microsoft.Exchange.WebServices.Data.CalendarView]::new([datetime]::Now,[datetime]::Now.AddDays(2))
$CalendarFolder.FindAppointments($View)
}
end {
}
}