问题
I try to Delete an phone number Entry within an contact while using the ExchangeWebService and powershell.
I can create new Contacts with Numbers and so on. I can even change those numbers. But i can set then to $null
or ""
.
It always gives me Exception calling "Update" with "1" argument(s): "An object within a change description must contain one and only one property to modify."
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)
The problem lies in this line $c.PhoneNumbers[$enumBusinessPhoneValue] = ""
even if i put in $null
i get the same error.
Greetings skratter
回答1:
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)
来源:https://stackoverflow.com/questions/48567877/ews-delete-phonenumber-entry-on-contact