locked
Import Telephone Number using CSV RRS feed

  • Question

  • Hi,

    While I am trying to run this:

    Import-Csv C:\UpdatedUsers.csv | ForEach-Object {Set-ADUser -Identity $_.samAccountName -Replace @{telephoneNumber=$_.telephoneNumber}}



    I am getting errors in row like this:

    Set-ADUser : replace
    At line:1 char:50
    + Import-Csv C:\UpdatedUsers.csv | ForEach-Object {Set-ADUser -Identity $_.samAcco ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (XXX:ADUser) [Set-ADUser], ADInvalidOperationException
        + FullyQualifiedErrorId : ActiveDirectoryServer:0,Microsoft.ActiveDirectory.Management.Commands.SetADUser

    When try to run this:

    Import-Csv C:\UpdatedUsers.csv | ForEach-Object { Set-ADUser -Identity $_.SamAccountName  -telephoneNumber $_.telephoneNumber} 


     

    I got this:

    Set-ADUser : A parameter cannot be found that matches parameter name 'telephoneNumber'.
    At line:1 char:91
    + ... amAccountName  -telephoneNumber $_.telephoneNumber}
    +                    ~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
        + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.SetADUse

    But if I am running it per user like this:

    Set-ADUser wattada -Replace @{telephoneNumber="000-00000"}


    The purpose is to replace current telephoneNumber which appears on general tab of user properties 

    it is works like charm.

    What do I miss here?


    Windows IT MVP 2015 /2016 www.PelegIT.co.il Thank you!




    • Edited by Meir Peleg Monday, June 26, 2017 7:56 AM
    Monday, June 26, 2017 7:48 AM

Answers

  • Hi,

    I have managed, Probably while we have some users with empty telephone field it is tangling up with Set-ADUser, as soon as I have filter it to represent me only filled fields and then re-run the the script it's worked amazing. 

    Thanks for assistance trying.


    Windows IT MVP 2015 /2016 www.PelegIT.co.il Thank you!

    • Marked as answer by Meir Peleg Monday, June 26, 2017 1:15 PM
    Monday, June 26, 2017 1:15 PM

All replies

  • You need to fix your CSV file.


    \_(ツ)_/

    Monday, June 26, 2017 8:00 AM
  • You need to fix your CSV file.


    \_(ツ)_/

    I am able to read my CSV... what do you think it is wrong there?

    Windows IT MVP 2015 /2016 www.PelegIT.co.il Thank you!

    Monday, June 26, 2017 8:35 AM
  • Hi,

    I have managed, Probably while we have some users with empty telephone field it is tangling up with Set-ADUser, as soon as I have filter it to represent me only filled fields and then re-run the the script it's worked amazing. 

    Thanks for assistance trying.


    Windows IT MVP 2015 /2016 www.PelegIT.co.il Thank you!

    • Marked as answer by Meir Peleg Monday, June 26, 2017 1:15 PM
    Monday, June 26, 2017 1:15 PM