AD: Adding Mobile and Telephone number to Notes

Welcome Forums General PowerShell Q&A AD: Adding Mobile and Telephone number to Notes

This topic contains 4 replies, has 4 voices, and was last updated by

 
Participant
1 month, 1 week ago.

  • Author
    Posts
  • #122754

    Participant
    Points: 13
    Rank: Member

    Hello.

    Is it possible to copy the values from mobile and telephone number to Notes under the tab Telephones on a AD-user?

    I have tried to do it like this: set-aduser ADUSER -Replace ${info} but I'm not sure how to add the correct variables to this command

     

  • #122775

    Moderator
    Points: 174
    Team MemberHelping Hand
    Rank: Participant

    Something like this should help.

    Get-ADUser -filter "your filter" -Properties telephoneNumber, OfficePhone | Foreach-Object { 
        Set-ADUser $_.samaccountname -replace @{info="$($_.telephoneNumber)`n$($_.OfficePhone)"}
    }
    
  • #122778

    Participant
    Points: 263
    Helping Hand
    Rank: Contributor

    Is it possible to copy the values from mobile and telephone number to Notes under the tab Telephones on a AD-user?

    Yes. That's definiteley possible

    I have tried to do it like this: set-aduser ADUSER -Replace ${info} but I'm not sure how to add the correct variables to this command

    You will have to get the information first before you can set it for other attributes. So you have to combine a

    Get-ADUser -Identity "sAMAccountName" -Properties OfficePhone,MobilePhone

    with a

    Set-ADUser -Replace @{info="$_.OfficePhone $_.MobilePhone"}
    
    
    		
    	
  • #122781

    Participant
    Points: 324
    Helping Hand
    Rank: Contributor

    If you don't know what a cmdlet is looking for, the first place to look is Get-Help:

    Get-Help Set-ADUser -Full
    

    You would see...

        -Replace [hashtable];
            
            Required?                    false
            Position?                    Named
            Accept pipeline input?       false
            Parameter set name           Identity
            Aliases                      None
            Dynamic?                     true
    

    On the question of is it possible, yes it is. You need to use Get-ADUser to get the attributes, format them (e.g. comma separated, semi-colon, separate lines), and then use Set-ADUser to set the info attribute:

    $user = Get-ADUser -Identity Rob
    $user | Set-ADUser -Replace @{'info', $user.Sid}
    
  • #122795

    Participant
    Points: 13
    Rank: Member

    Something like this should help.

    PowerShell
    4 lines

    1
    2
    3
    4
    Get-ADUser -filter "your filter" Properties telephoneNumber, OfficePhone | Foreach-Object {
    Set-ADUser $_.samaccountname -replace @{info="$($_.telephoneNumber)`n$($_.OfficePhone)"}
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Thank you very much – it works!

You must be logged in to reply to this topic.