locked
Simple question data import in AD RRS feed

  • Question

  • Hi) I'm a beginner of PowerShell and I love microsoft products. Pls help me.

    I'm trying to set business position  from a csv file to Active Directory base. 


    My csv file has the following view :

    Position Name

     XXX       XXX

    The Name from csv file field is the last name and matches the Surname of object in active directory property

    I do the following:

    Import-Csv D:\PS\UsersEdit.ru.en_test.csv -Delimiter ";" | ForEach-Object { Get-ADUser -Filter { Surname -eq $_.Name} | Set-ADUser -Title $_.Position}

    What am I doing wrong? help me please


    Thursday, May 16, 2019 2:42 PM

Answers

  • You cannot correctly match an object in AD with only a surname.

    Start by correctly formatting and posting your code. You cannot use "{}" when using an object property. You also must correctly quote the object and its property.


    \_(ツ)_/

    Thursday, May 16, 2019 4:50 PM

All replies

  • What's your problem?

    Have you verified that you're actually finding a user object? What will you do if you don't?

    Just a bit of advice . . . using only a surname to identify an AD object it risky. What happens if you find more than one object that matches your criteria?


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Thursday, May 16, 2019 3:21 PM
  • You cannot correctly match an object in AD with only a surname.

    Start by correctly formatting and posting your code. You cannot use "{}" when using an object property. You also must correctly quote the object and its property.


    \_(ツ)_/

    Thursday, May 16, 2019 4:50 PM
  • Hi,
    Was your issue resolved? 
    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.
    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.
    If no, please reply and tell us the current situation in order to provide further help.
    Best Regards,
    Lee

    Just do it.

    Monday, May 20, 2019 6:32 AM