【发布时间】:2015-08-22 16:12:18
【问题描述】:
我需要协助将预订/会议导入 office365。我可以将我们旧的基于 Web 的系统中的预订信息导出到 csv 中,但需要一种方法来导入到 office365 中的交换中。
我发现的最有前途的方法是使用 Exchange Web 服务通过 powershell 连接到云,然后使用模拟将预订重新定义为针对新创建的房间邮箱的适当用户。但如果有更好的方法,我愿意接受其他建议。
我目前在使用 EWS 和 powershell(例如:http://mikepfeiffer.net/2011/01/creating-calendar-items-with-powershell-and-the-ews-managed-api/)时遇到的问题是,当我尝试连接时出现自动发现错误。使用 office 365 仍然可以做到这一点吗?
更新: 嗨格伦秤,
非常感谢您的示例,看起来很有希望,但是当我在上面运行您的代码时,我仍然遇到自动发现错误,具体错误以及我在下面逐步说明的操作。我希望我做的事情显然是错误的,你将能够纠正我
我正在运行 powershell 并使用我们的凭据连接到 o365,如下所示:
$loginUserName = "admin@domain.onmicrosoft.com"
$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
然后加载你的函数并尝试这样的测试命令:
$Start = Get-Date
$End = (Get-Date).AddHours(1)
Create-Appointment -MailboxName mymailbox@domain.com -Subject "Test appointment" -Start $Start -End $End -Body "Test Body" -Credentials $Credential -Location "sdfkjhsdfjh"
错误:
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
【问题讨论】:
标签: powershell office365 exchange-server impersonation