EWS | Powershell:加载日历项扩展属性

EWS | Powershell:加载日历项扩展属性,powershell,exchangewebservices,Powershell,Exchangewebservices,我正在尝试将一组扩展属性加载到“其他”中的日历约会对象中,以报告和操作它们。然而,我在这方面遇到了麻烦。每当它到达需要加载扩展属性的行时,就会出现以下错误:“使用“1”参数调用“load”时发生异常:““不能使用属性标记指定自定义属性”。必须使用GUID和Id/名称组合来代替”” 我遇到的问题是: $apapoint.Load($psPropset) 整个代码如下。感谢您的帮助。顺便说一下,我还是EWS的初学者。谢谢 Report=@() $MailboxList=Read Host“输入保存用

我正在尝试将一组扩展属性加载到“其他”中的日历约会对象中,以报告和操作它们。然而,我在这方面遇到了麻烦。每当它到达需要加载扩展属性的行时,就会出现以下错误:“使用“1”参数调用“load”时发生异常:““不能使用属性标记指定自定义属性”。必须使用GUID和Id/名称组合来代替”

我遇到的问题是: $apapoint.Load($psPropset)

整个代码如下。感谢您的帮助。顺便说一下,我还是EWS的初学者。谢谢
Report=@()
$MailboxList=Read Host“输入保存用户的txt文件的路径。”
$StartDate=获取日期2013年1月1日
$EndDate=获取日期2013年4月1日
#$StartDate=新对象系统的日期时间(2014年8月27日)
#$EndDate=新对象系统.DateTime(2015,02,28)
#使用默认凭据登录到Exchange Web服务
添加类型-路径“C:\Program Files\Microsoft\Exchange\Web Services\2.2\Microsoft.Exchange.WebServices.dll”
$sid=[System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value
$user=[ADSI]“LDAP://”
$service=新对象Microsoft.Exchange.WebServices.Data.ExchangeService-ArgumentList([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010\U SP2)
$service.AutodiscoverUrl($user.Properties.mail)
写入进度-活动“正在准备”-状态“正在检索邮箱列表”-完成百分比0
$Mailboxes=cat$MailboxList |获取邮箱
$Count=$mailboxs.Count
#检查每个用户找到的
ForEach($邮箱中的邮箱){
$DisplayName=$Mailbox.DisplayName
#$i=$i+1
#$pct=$i/$Count*100
#写入进度-活动“收集邮箱详细信息”-状态“处理邮箱$i共$Count-$DisplayName”-完成百分比$pct
试一试{
$Ok=$true
$Mailbox=(获取邮箱$Mailbox.WindowsEmailAddress-ErrorAction-Stop)。PrimarySMTPAddress}
catch[系统异常]{
$Ok=$false
}
如果($Ok){
#设置EWS以模拟所有用户
$ImpersonatedUserId=新对象Microsoft.Exchange.WebServices.Data.ImpersonatedUserId-ArgumentList([Microsoft.Exchange.WebServices.Data.ConnectionIDType]::SmtpAddress),$Mailbox
$service.ImpersonatedUserId=$ImpersonatedUserId
#打开用户文件夹并将日历文件夹绑定到EWS服务。然后,将每个日历默认视图设置为1000
$folderid=新对象Microsoft.Exchange.WebServices.Data.folderid([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::日历,$Mailbox)
$CalendarFolder=[Microsoft.Exchange.WebServices.Data.CalendarFolder]::绑定($service,$folderid)
$cvCalendarview=新对象Microsoft.Exchange.WebServices.Data.CalendarView($StartDate,$EndDate,1000)
#查询日历并返回约会
$cvCalendarview.PropertySet=新对象Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
$frCalendarResult=$CalendarFolder.FindAppoints($cvCalendarview)
foreach($frCalendarResult.Items中的apApointment){
#检查每个日历项目并收集它们的属性
$psPropset=新对象Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
#创建扩展属性
$PR_SENT_表示_NAME=新对象Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(0x42,[Microsoft.Exchange.WebServices.Data.MapPropertyType]::字符串)
$PR\u SENDER\u NAME=新对象Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(0xc1a[Microsoft.Exchange.WebServices.Data.MapPropertyType]::字符串)
$dispidApptTZDefStartDisplay=新对象Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(0x825E[Microsoft.Exchange.WebServices.Data.MapipPropertyType]::字符串)
$dispidApptTZDefEndDisplay=新对象Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(0x825F[Microsoft.Exchange.WebServices.Data.MapPropertyType]::字符串)
$ptagSentRepresentingSimpleDispName=新对象Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(0x4031[Microsoft.Exchange.WebServices.Data.MapPropertyType]::字符串)
#将扩展属性添加到属性集
$psPropset.Add($PR\u SENDER\u NAME);
$psPropset.Add($PR\u SENT\u代表\u NAME);
$psPropset.Add($dispidApptTZDefStartDisplay);
$psPropset.Add($dispidApptTZDefEndDisplay);
$psPropset.Add($ptagSentRepresentingSimpleDispName);
#将属性添加到日历视图
$cvCalendarview.PropertySet=$psPropset;
#将属性加载到当前约会中
**$apApointment.Load($psPropset)**
$SENDER_NAME=@()
$SENT_表示_NAME=@()
$TZDefStartDisplay=@()
$tzdisplay=@()
$ptagsenrepsimplename=@()
$apApointment.TryGetProperty($PR_SENT_表示_NAME,[ref]$SENT_表示_NAME)
$apApointment.TryGetProperty($PR\u SENDER\u NAME,[ref]$SENDER\u NAME)
$apApointment.TryGetProperty($dispidApptTZDefStartDisplay,[ref]$TZDefStartDisplay)
$apApointment.TryGetProperty($dispidApptTZDefEndDisplay,[ref]$TZDefEndDisplay)
$ApaPoint.TryGetProperty($PTAGEnterpresentingsImpledSpName,[ref]$PTAGEnterprisImpleName)
$app=$apApointment.Subject
$start=$apApointment.start
$End=$apApointment.End
$WhenCreated=$apApointment.DateTimeCreated
$Organizer=($apApointment.Organizer).地址
$Required=$apApointment.requiredAttenders.Count
$recurtive=$apApointment.isrecuring
#准备报表所需的对象
$Obj=新对象-类型名称PSObject
$Obj |添加成员-成员类型NoteProperty-姓名会议主题-价值$app
$Obj |添加成员-成员类型NoteProperty-名称会议开始时间-值$start
$Obj |添加成员-成员类型NoteProperty-名称MeetingEndTime-值$End
$Obj |添加成员-成员类型NoteProperty-名称
$dispidApptTZDefStartDisplay = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition([Microsoft.Exchange.WebServices.Data.DefaultExtendedPropertySet]::Appointment, 0x825E,[Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Binary)
$dispidApptTZDefEndDisplay = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition([Microsoft.Exchange.WebServices.Data.DefaultExtendedPropertySet]::Appointment, 0x825F,[Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Binary)