Difference between AD mobile and mobilephone property

This topic contains 2 replies, has 2 voices, and was last updated by  Yuan Li 1 year, 9 months ago.

  • Author
    Posts
  • #36557

    Yuan Li
    Participant

    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

  • #36559

    Dave Wyatt
    Moderator

    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
    
  • #36588

    Yuan Li
    Participant

    Thanks Dave!

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

    Cheers
    Yuan

You must be logged in to reply to this topic.