locked
How set-aduser to modify the AD attribute "Telephone Number" RRS feed

  • Question

  • Hi,

    Does anyone know How set-aduser to modify the AD attribute "Telephone Number" ?

    Monday, September 10, 2012 7:46 AM

Answers

  • Import-Csv 'd:\postcode.csv' | % { Set-ADUser -Identity $_.name -OfficePhone $_.OfficePhone -WhatIf}


    Grant Ward, a.k.a. Bigteddy


    • Edited by Bigteddy Monday, September 10, 2012 8:54 AM
    • Proposed as answer by Bigteddy Monday, September 10, 2012 9:15 AM
    • Marked as answer by Human Being_001 Monday, September 10, 2012 9:26 AM
    Monday, September 10, 2012 8:53 AM
  • Set-ADUser Sam -Add @{telephonenumber="123123"}

    • Edited by Kazun Monday, September 10, 2012 7:59 AM
    • Marked as answer by Yan Li_ Wednesday, September 12, 2012 7:39 AM
    Monday, September 10, 2012 7:58 AM

All replies

  • Set-ADUser samw -OfficePhone '0211232222'


    Grant Ward, a.k.a. Bigteddy

    Monday, September 10, 2012 7:54 AM
  • Set-ADUser Sam -Add @{telephonenumber="123123"}

    • Edited by Kazun Monday, September 10, 2012 7:59 AM
    • Marked as answer by Yan Li_ Wednesday, September 12, 2012 7:39 AM
    Monday, September 10, 2012 7:58 AM
  • Sorry, the error is:

    PS C:\Windows\system32> Import-Csv 'd:\postcode.csv' | % { Set-ADUser -Identity
    $_.name $_.OfficePhone -WhatIf}
    Set-ADUser : A positional parameter cannot be found that accepts argument '123456'.
    At line:1 char:46
    • Proposed as answer by mhedv Wednesday, November 14, 2012 2:00 PM
    • Unproposed as answer by mhedv Wednesday, November 14, 2012 2:00 PM
    • Proposed as answer by KMGUKHC Thursday, October 17, 2013 5:35 PM
    Monday, September 10, 2012 8:04 AM
  • You have to use a named parameter:

    -OfficePhone <string>
            Specifies the user's office telephone number. This parameter sets the OfficePhone property of a user object. The LDAP display name (ldapDisplayName) of this 
            property is "telephoneNumber".
            
            The following example shows how to set this parameter.
              -OfficePhone  "+1 (999) 555 1212"
            
            Required?                    false
            Position?                    named
            Default value                
            Accept pipeline input?       false
            Accept wildcard characters?  false


    Grant Ward, a.k.a. Bigteddy


    • Edited by Bigteddy Monday, September 10, 2012 8:25 AM
    Monday, September 10, 2012 8:23 AM
  • Sorry, it's not easy for me.

    Could point me more detial about how I can change the script to meet the request?

    Thanks.

    Monday, September 10, 2012 8:49 AM
  • Import-Csv 'd:\postcode.csv' | % { Set-ADUser -Identity $_.name -OfficePhone $_.OfficePhone -WhatIf}


    Grant Ward, a.k.a. Bigteddy


    • Edited by Bigteddy Monday, September 10, 2012 8:54 AM
    • Proposed as answer by Bigteddy Monday, September 10, 2012 9:15 AM
    • Marked as answer by Human Being_001 Monday, September 10, 2012 9:26 AM
    Monday, September 10, 2012 8:53 AM
  • Thanks so much.
    Monday, September 10, 2012 9:25 AM
  • Hi Bigteddy,

    I am trying to modifying the below information for existing users using CSV file. Could you help me to do it through Power Shell.

    Scenario:

    I have 50 Users where I want to modify "Othertelephone" & "info" for those object. These are AD attributes and you can see under respectively: General >> Telephone Number >>Other and Telephone >> Notes.

    I want to look users from .csv file and modify above attributes for mentioned users in csv file.

    Thanks

    Shambhu Sharma

    Friday, November 29, 2013 10:14 PM
  • Hi Bigteddy,

    I am trying to modifying the below information for existing users using CSV file. Could you help me to do it through Power Shell.

    Scenario:

    I have 50 Users where I want to modify "Othertelephone" & "info" for those object. These are AD attributes and you can see under respectively: General >> Telephone Number >>Other and Telephone >> Notes.

    I want to look users from .csv file and modify above attributes for mentioned users in csv file.

    Thanks

    Shambhu Sharma

    Well, all you need to do is to modify the attributes (add otherTelephone and info) from the answer earlier in this thread.

    Something like:

    Import-CSV "C:\Users.csv" | % {
    $User = $_.UserName
    $Info = $_.Info
    Set-ADUser $User -info $info
    }

    Saturday, November 30, 2013 2:33 PM
  • Hi,

    It did´t work. Below are error:

    Set-ADUser : A parameter cannot be found that matches parameter name 'info'.
    At C:\altools\Info.ps1:1 char:115
    + Import-CSV "C:\altools\testaccount55.csv" | % { $User = $_.SamAccountName; $Info = $_.Info; Set-adUser $User -info <<
    <<  $info }
        + CategoryInfo          : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
        + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.SetADUser

    Otherway:

    Set-ADUser : A parameter cannot be found that matches parameter name 'othertelephone'.
    At C:\altools\Info.ps1:1 char:107
    + Import-CSV "C:\altools\testaccount55.csv" | % {$User = $_.SamAccountName; Set-adUser $User -othertelephone <<<<  $_.o
    thertelephone -info $_.info}
        + CategoryInfo          : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
        + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.SetADUser

    My Script:

    Import-CSV "C:\altools\testaccount55.csv" | % {$User = $_.SamAccountName; Set-adUser $User -othertelephone $_.othertelephone -info $_.info}

    From my understanding these two attributed are not acceptable from New-ADUser and Set-ADUser Powershell command.

    I am not sure whether we have any other option to put these do attributes data using the other command but importing the same csv file.

    Thanks Shambhu

    Monday, December 2, 2013 5:51 PM
  • Monday, December 2, 2013 6:02 PM
  • Import-Csv 'd:\postcode.csv' | % { Set-ADUser -Identity $_.name -OfficePhone $_.OfficePhone -WhatIf}


    Grant Ward, a.k.a. Bigteddy



    Set-AdUser: Cannot validate argument on parameter 'Identity'...
    Friday, January 20, 2017 7:30 PM
  • Please open your own topic.  This one was closed 4 years ago.

    \_(ツ)_/

    Friday, January 20, 2017 7:45 PM