none
How do I filter Get-Aduser output and export to a CSV only the attributes I need?

    Question

  • Hello,

    What I want to do is based on a list of IDs, or CNs, generate a CSV file with Col1 being the ID or CN and Col2 being the EmployeeID.

    I run the following command which imports a list of IDs, or CNs.  I then search the directory and find the matching EmployeeID, but then how do I filter/export the ID/CN and EmployeeID to a CSV file only?  What happens with the export is I get additional attributes I dont want. Thanks in advance.

    Import-csv cu1.csv | foreach-object {get-aduser -identity $_.ID -properties cn,employeeid} | Export-csv file1.csv

     


    Thanks for your help! SdeDot
    Tuesday, December 13, 2011 5:57 PM

Answers

  • Import-csv cu1.csv |
     foreach-object {get-aduser -identity $_.ID -properties cn,employeeid} |
     select cn,employeeid |
     Export-csv file1.csv
    


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    • Proposed as answer by Rich Prescott Tuesday, December 13, 2011 6:09 PM
    • Marked as answer by SdeDot Tuesday, December 13, 2011 6:18 PM
    Tuesday, December 13, 2011 6:06 PM

All replies

  • Import-csv cu1.csv |
     foreach-object {get-aduser -identity $_.ID -properties cn,employeeid} |
     select cn,employeeid |
     Export-csv file1.csv
    


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    • Proposed as answer by Rich Prescott Tuesday, December 13, 2011 6:09 PM
    • Marked as answer by SdeDot Tuesday, December 13, 2011 6:18 PM
    Tuesday, December 13, 2011 6:06 PM
  • Thanks mjolinor...works great!
    Thanks for your help! SdeDot
    Tuesday, December 13, 2011 6:18 PM
  • No problem. 
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Tuesday, December 13, 2011 6:24 PM