Difference between AD mobile and mobilephone property

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Yuan Li Yuan Li 8 months, 4 weeks ago.

  • Author
    Posts
  • #36557
    Profile photo of Yuan Li
    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
    Profile photo of Dave Wyatt
    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
    Profile photo of Yuan Li
    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.