Exchange web services: Difference between revisions

From WikiWiki
Jump to navigation Jump to search
(Created page with " <syntaxhighlight lang="powershell"> #powershell proof of concept code to list entries in calendar #ews exchange web services $Credentials = New-Object Microsoft.Exchange.W...")   (change visibility)
 
No edit summary   (change visibility)
 
Line 2: Line 2:




<syntaxhighlight lang="powershell">
<syntaxhighlight language="powershell">
#powershell proof of concept code to list entries in calendar
#powershell proof of concept code to list entries in calendar
#ews exchange web services
#ews exchange web services

Latest revision as of 22:50, 21 August 2020


#powershell proof of concept code to list entries in calendar
#ews exchange web services

$Credentials = New-Object Microsoft.Exchange.WebServices.Data.WebCredentials("username@restofemailadres.org","password")#,"domain")

Add-Type -Path "C:\Program Files (x86)\Microsoft\Exchange\Web Services\2.1\Microsoft.Exchange.WebServices.dll"  

$version = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2 
$exchService = new-object Microsoft.Exchange.WebServices.Data.ExchangeService($version) 
#$exchService = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService
$exchService.Credentials = $Credentials


# Your mailbox here
$mailboxName = "username@restofemailadres.org"

#extra check on autodiscover
$RedirectionCallback = {
 param ([string] $url)
 if ($url -eq "https://autodiscover-s.outlook.com/autodiscover/autodiscover.xml") {$true} else {$false}
}


$exchService.AutodiscoverUrl($mailboxName, $RedirectionCallback)

$folderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar, $mailboxName)
$calendarFolder = [Microsoft.Exchange.WebServices.Data.calendarFolder]::Bind($exchService, $folderid)
$calendarView = new-object Microsoft.Exchange.WebServices.Data.CalendarView([System.DateTime]::Now, [System.DateTime]::Now.AddDays(720))
$calendarView.MaxItemsReturned = 200;
$calendarView.PropertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
$result = $calendarFolder.FindAppointments($calendarView)

$result | out-gridview

http://msdn.microsoft.com/en-us/library/jj900168%28v=exchg.80%29.aspx

http://msdn.microsoft.com/en-us/library/dn567668%28v=exchg.150%29.aspx

Download: http://go.microsoft.com/fwlink/?LinkID=255472