Author Posts

March 14, 2016 at 4:34 pm

Hey Guys,

I meet a strange issue, not sure if it's a bug or feature. I want to update someone's mobile number in AD like that

get-aduser -identity $user -Properties name,mobile | Set-ADUser -Replace @{mobile=$num}

It's working, but when I use mobilephone instead of mobile, I got an error message

set-aduser : The specified directory service attribute or value does not exist

if I just run get-aduser and get-member, both properties return the same result but why I can't use mobilephone in the set-aduser comlet?

Cheers
Yuan

March 14, 2016 at 7:44 pm

The AD cmdlets try to be "helpful" by creating some friendlier names for properties than the underlying LDAP names. "mobile" is an LDAP property name; MobilePhone is what the AD module wraps in the objects. When you're using the -Replace parameter, you're working with generic LDAP property names.

If you want to use the friendlier names, do this instead:

Get-ADUser -identity $user -Properties name,mobile | Set-ADUser -MobilePhone $num

Incidentally, you could also just do this instead of using a pipeline:

Set-ADUser -Identity $user -MobilePhone $num

March 15, 2016 at 1:35 pm

Thanks Dave!

I checked the help of set-ADuser and in the syntax it only include mobilephone property.

Cheers
Yuan