Error deleting existing multivalued parameter from an Office 365 Contact using Set-Contact cmdlet

Q: How can I update existing O365 Contacts to remove some, or all, of the values associated with a multivalued parameter (e.g., OtherTelephone and OtherHomePhone.)

Using Powershell Exchange Set-Contact cmdlet with Office 365

For other parameters, simply specifying an empty string value to a SetContact parameter is sufficient to update them to empty.

For multivalued parameters, using something like -OtherTelephone "" as the parameter produces:

Set-Contact -Identity -ErrorAction Continue -WarningAction SilentlyContinue -OtherTelephone "" -TelephoneAssistant "123-456-7890" -Office "" -Pager "" -HomePhone "123-456-7891" -Title "Records Ch" -Notes "" -OtherHomePhone "" -Fax "" -Initials "ZY" -Department "" -StreetAddress "1234 My Lane" -PostalCode "12345-1234" -MobilePhone "123-456-7892" -StateOrProvince "DC" -Company "" -City "Cityname" -Phone ""

Active Directory operation failed on DM3PR12A003DC04.NAMPR12A003.PROD.OUTLOOK.COM. This error is not retriable.        
Additional information: The attribute specified in the operation is not present on the object.                          
Active directory response: 00002076: AtrErr: DSID-030F18BB, #2:                                                                
   0: 00002076: DSID-030F18BB, problem 1001 (NO_ATTRIBUTE_OR_VAL), data 0, Att 20115 (otherHomePhone)                      
   1: 00002076: DSID-030F18BB, problem 1001 (NO_ATTRIBUTE_OR_VAL), data 0, Att 20012 (otherTelephone)                  
+ CategoryInfo          : NotSpecified: (:) [Set-Contact], ADOperationException                                        
+ FullyQualifiedErrorId : [Server=CY4PR1201MB0199,RequestId=16e078fa-23f1-44d9-89ab-8d0df28628ec,TimeStamp=2/8/201    
8 10:09:21 PM] [FailureCategory=Cmdlet-ADOperationException] 4B85200D,Microsoft.Exchange.Management.RecipientTasks    
  + PSComputerName        :
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vasil Michev (MVP)Commented:
Since it's a multi-value, "" will only work when it's non-empty. Either check for the value, or simply use the following notation to quick add/remove:

Set-Contact temp -OtherTelephone @{add="+123"}
Set-Contact temp -OtherTelephone @{remove="+123"}

Open in new window

fmoultrieAuthor Commented:
That's helpful, but not fully what I need. I am replacing a series of contact fields and am trying to just set the new values without comparing each to the previous (which can be done, but doesn't appear trivial to implement).

In this case, the specified replacement string is empty and I'd like to just blindly replace the existing field value (e.g., the OtherTelephone value, whether empty or not) with an empty value.

I suppose I could retrieve the contact information, loop through the multi-value fields in the contact, and iteratively @{remove="each"}. I would much prefer to just be able to reset a contact multi-value field in a single operation.

Is there anything like the related AD operation such as an @{clear} or other way to reset a multi-value field regardless of current value? Or, would the iterative @{remove approach be simple to implement? (example appreciated, if so)

Vasil Michev (MVP)Commented:
Simply set it to $null then.

Set-Contact temp -OtherTelephone $null

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fmoultrieAuthor Commented:
Thank you!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.