EWS删除联系人上的电话号码条目 [英] EWS Delete PhoneNumber Entry on Contact
问题描述
我尝试在使用ExchangeWebService和powershell时删除联系人中的电话号码条目。
I try to Delete an phone number Entry within an contact while using the ExchangeWebService and powershell.
我可以使用数字创建新的联系人,依此类推。我什至可以更改这些数字。但是我可以将其设置为 $ null
或
。
I can create new Contacts with Numbers and so on. I can even change those numbers. But i can set then to $null
or ""
.
它总是给我用 1作为参数调用 Update的异常:更改描述中的对象必须包含一个且只能更改一个属性。
我知道即时消息不允许将其设置为或null。但是必须有一种删除电话号码条目的方法。
I understand that im not allowed to set it to "" or null. But there have to be a way to delete a phone number entry.
因此,可能有人在那里帮助我解决此问题。
So may be there is someone out there to help me with this issue.
到目前为止,我检查电话号码是否有更改,仅在有更改的地方进行更新。
So far i check if there is a change in the phone number and only update it where there is.
$enumBusinessPhoneValue = [Microsoft.Exchange.WebServices.Data.PhoneNumberKey]::BusinessPhone
if($c.PhoneNumbers[$enumBusinessPhoneValue] -ne "" -and $c.PhoneNumbers[$enumBusinessPhoneValue] -ne $null){
if($busPhone -ne ""){
if($c.PhoneNumbers[$enumBusinessPhoneValue] -ne $busPhone){
echo "="
$c.PhoneNumbers[$enumBusinessPhoneValue] = $busPhone
}
} else {
$c.PhoneNumbers[$enumBusinessPhoneValue] = ""
}
} else {
if($busPhone -ne ""){
$c.PhoneNumbers[$enumBusinessPhoneValue] = $busPhone
}
}
$c.Update([Microsoft.Exchange.WebServices.Data.ConflictResolutionMode]::AlwaysOverwrite)
问题出在此行 $ c.PhoneNumbers [$ enumBusinessPhoneValue ] =
即使我放入 $ null
我也遇到相同的错误。
The problem lies in this line $c.PhoneNumbers[$enumBusinessPhoneValue] = ""
even if i put in $null
i get the same error.
问候
skratter
Greetings skratter
推荐答案
在这种情况下,您需要使用商务电话的扩展属性(这是与EmailAdddresses > https://blogs.msdn.microsoft.com/emeamsgdev/2012/05/17/ews-managed-api-how-to-remove-email1-email2-email3-来自),例如
You need to use the Extended Property for the Business Phone in this case (this is the same as for EmailAdddresses https://blogs.msdn.microsoft.com/emeamsgdev/2012/05/17/ews-managed-api-how-to-remove-email1-email2-email3-from-a-contact/) eg
$PidTagBusinessTelephoneNumber = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(0x3A08,[Microsoft.Exchange.WebServices.Data.MapiPropertyType]::String);
$c.RemoveExtendedProperty($PidTagBusinessTelephoneNumber)
$c.Update([Microsoft.Exchange.WebServices.Data.ConflictResolutionMode]::AlwaysOverwrite)
这篇关于EWS删除联系人上的电话号码条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!