locked
Powershell - Get information about users and export to CSV RRS feed

  • General discussion

  • Hi,

    I have in CSV users First Name nad Surname. I want to use this CSV to get form AD information about them and export this to CSV. 

    Information what I need is: First Name, Surname, DisplayName, Street address, City, Postal Code, telephons, Job Title, Department.

    How can I do this?

    • Changed type Bill_Stewart Friday, July 27, 2018 9:12 PM
    • Moved by Bill_Stewart Friday, July 27, 2018 9:12 PM This is not "scripts on demand"
    Wednesday, May 30, 2018 8:16 AM

All replies

  • This forum doesn't just write scripts for you. Learn PowerShell and attempt this issue first to let us know the SPECIFIC issues you are having.

    A rough sketch would be to join the first and last name and then do a get-aduser search using that.

    THIS IS A DUPLICATE, JUST REALISED!

    https://social.technet.microsoft.com/Forums/en-US/ef520e29-f574-4301-8e03-17c176d154c8/get-information-about-users-and-export-to-csv?forum=winserverpowershell


    Learn PowerShell                     Script Requests

    -Remember to mark the correct response as the answer-


    Wednesday, May 30, 2018 8:29 AM
  • You would use Import-Csv and and Get-ADUser. Example (not tested):


    Import-Csv MyCSVFile.csv | ForEach-Object {
      Get-ADUser -LDAPFilter ("(&(givenName={0})(sn={1}))" -f $_.FirstName,$_.LastName) -Properties ... |
      Select-Object SurName,GivenName,DisplayName,Address,...
    } | Export-Csv NewCSVFile.Csv -NoTypeInformation
    

    You will need to put the appropriate column names from the CSV file after $_ (after the -f operator) and then put the appropriate property names after the -Properties parameter of Get-ADUser and also after Select-Object.


    -- Bill Stewart [Bill_Stewart]

    Wednesday, May 30, 2018 12:31 PM