PowerShell: Set-ADUser : Multiple values were specified for an attribute that can have only one value

A nice little gottcha.

We use one of AD’s Extension Attibutes to hold specific information about our users. Recently rewriting a VBScript in PowerShell I ran into a little wall when it came to adding an Extension Attibute.

Here is the correct code:

There’s nothing wrong with that and it will work, unless (and here’s the catch) there is already a value in the attribute. If there is, expect a similar error to:

To work around the problem, replace “-Add” with “-Replace”. For example:

In my testing, even if the attribute was $null, it would still add. I also observed, -Add will work if you are trying to replace with the same value.

2 thoughts on “PowerShell: Set-ADUser : Multiple values were specified for an attribute that can have only one value

Please feel free to leave a comment...