I need assistance importing bookings/meetings into office365. I can export the booking information from our old web-based system into csv, but need a way to import into exchange in office365.
The most promising method I have found is using Exchange Web Services to connect to the cloud with powershell an then use impersonation to re-reate the bookings as the appropriate users against the newly created room mailboxes. But I am open to other suggestions if there is a better way.
The problem I have currently with EWS and powershell (like this: http://mikepfeiffer.net/2011/01/creating-calendar-items-with-powershell-and-the-ews-managed-api/) is that when I try to connect I get Autodiscover errors. Is this still possible using office 365?
Update: Hi Glen Scales,
Thank you kindly for your example, looks promising, but I am still getting a autodiscover error when I run your code above, specific error(s) and description of what I am doing step by step below. I am hoping I am doing something obviously wrong and you will be able to correct me
I am running powershell and connecting to o365 with our credentials like this:
$loginUserName = "[email protected]"
$PWord = ConvertTo-SecureString –String "secret" –AsPlainText -Force
$Credential = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $loginUserName, $PWord
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Credential -Authentication Basic -AllowRedirection
Import-PSSession $Session
Connect-MsolService -Credential $Credential
Then loading your function and trying a test command like this:
$Start = Get-Date
$End = (Get-Date).AddHours(1)
Create-Appointment -MailboxName [email protected] -Subject "Test appointment" -Start $Start -End $End -Body "Test Body" -Credentials $Credential -Location "sdfkjhsdfjh"
Error:
Exception calling "AutodiscoverUrl" with "2" argument(s): "The Autodiscover service couldn't be located."
At \\blahblah\bookings.ps1:100 char:3
+ $service.AutodiscoverUrl($MailboxName,{$true})
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : AutodiscoverLocalException
Using CAS Server :
Exception calling "Bind" with "2" argument(s): "The Url property on the ExchangeService object must be set."
At \\blahblah\bookings.ps1:114 char:3
+ $Calendar = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folde ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ServiceLocalException
Exception calling "Save" with "2" argument(s): "Value cannot be null.
Parameter name: destinationFolderId"
At \\blahblah\bookings.ps1:127 char:3
+ $Appointment.Save($Calendar.Id,[Microsoft.Exchange.WebServices.Data.SendInvita ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentNullException
You need to make sure you use credentials in Office365 or you will get an Autodiscover error eg something like this should work