locked
Need help with a script to export some AD fields to csv or txt RRS feed

  • Question

  • What Im looking for is something to export some AD values to a file, right now just employeeID and mail attributes. Something that I could swap out attributes would work great. I have tried getting the proAddresses but is difficult to juggle. It seems to change when someone has one, many, or no email addresses.
    Tuesday, September 15, 2009 1:19 PM

Answers

  • use powershell! it should be pretty easy with the Quest cmdlets


    install powershell and these http://www.quest.com/activeroles-server/arms.aspx

    and you should be able to do somethng like to info from all users in AD.

    Get-QADUser | select-object empoyeeID, firstname, lastname | Export-CSV C:\Users.csv

    Select the fields yuo want in select-object.

    read quest help for help about the Get-QADUser and powershell documentation for the select-object and export-csv


    best regards

    Jakob
    Trainer/Consultant - Coretech A/S - Blog - MCT - MCTS - VB.NET - C#.NET - Powershell - VBScript
    • Proposed as answer by BSonPosh Tuesday, September 15, 2009 2:10 PM
    • Marked as answer by BSonPosh Tuesday, September 15, 2009 2:48 PM
    Tuesday, September 15, 2009 1:30 PM
  • employeeID is not in the default return set. You need to add it.

    Get-QADUser -IncludedProperties employeeID | select-object empoyeeID, firstname, lastname | Export-CSV C:\Users.csv

    Also... if you have more than 1000 users you will need to add -sl 0 to Get-QADUser

    Get-QADUser -IncludedProperties employeeID -sl 0 | select-object empoyeeID, firstname, lastname | Export-CSV C:\Users.csv
    Brandon Shell [MVP]
    • Proposed as answer by BSonPosh Tuesday, September 15, 2009 2:10 PM
    • Marked as answer by BSonPosh Tuesday, September 15, 2009 2:48 PM
    Tuesday, September 15, 2009 2:10 PM

All replies

  • use powershell! it should be pretty easy with the Quest cmdlets


    install powershell and these http://www.quest.com/activeroles-server/arms.aspx

    and you should be able to do somethng like to info from all users in AD.

    Get-QADUser | select-object empoyeeID, firstname, lastname | Export-CSV C:\Users.csv

    Select the fields yuo want in select-object.

    read quest help for help about the Get-QADUser and powershell documentation for the select-object and export-csv


    best regards

    Jakob
    Trainer/Consultant - Coretech A/S - Blog - MCT - MCTS - VB.NET - C#.NET - Powershell - VBScript
    • Proposed as answer by BSonPosh Tuesday, September 15, 2009 2:10 PM
    • Marked as answer by BSonPosh Tuesday, September 15, 2009 2:48 PM
    Tuesday, September 15, 2009 1:30 PM
  • Thanks. Ill give that a try.
    Tuesday, September 15, 2009 1:31 PM
  • It dosnt seem to let me pull employeeID, it works for things like mail, firstname, lastname. Things that are on the properties page of a user in AD. Does not seem to work for anything that is not.
    Tuesday, September 15, 2009 2:05 PM
  • employeeID is not in the default return set. You need to add it.

    Get-QADUser -IncludedProperties employeeID | select-object empoyeeID, firstname, lastname | Export-CSV C:\Users.csv

    Also... if you have more than 1000 users you will need to add -sl 0 to Get-QADUser

    Get-QADUser -IncludedProperties employeeID -sl 0 | select-object empoyeeID, firstname, lastname | Export-CSV C:\Users.csv
    Brandon Shell [MVP]
    • Proposed as answer by BSonPosh Tuesday, September 15, 2009 2:10 PM
    • Marked as answer by BSonPosh Tuesday, September 15, 2009 2:48 PM
    Tuesday, September 15, 2009 2:10 PM
  • This works great. Any idea how I could automate the running of this?
    Tuesday, September 15, 2009 2:45 PM
  • Taskscheduler
    Brandon Shell [MVP]
    Tuesday, September 15, 2009 2:48 PM
  • right but im not sure of the syntax as the quest stuff loads on top of the normal powershell.
    Tuesday, September 15, 2009 2:57 PM
  • oh... so it is just like any other exe.

    powershell.exe <script>
    Brandon Shell [MVP]
    Tuesday, September 15, 2009 3:14 PM
  • yeah you can run it as Brandon says.

    and to make sure you have the QAD Cmdlets loaded yu can add this line to the top of your script:

    Add-PSSnapin Quest.ActiveRoles.ADManagement

    this will give you an error message if it is already loaded, or load it if its not.

    to make sure you never get an error message you could do

    Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction "silentlycontinue"


    Best Regards Jakob


    Trainer/Consultant - Coretech A/S - Blog - MCT - MCTS - VB.NET - C#.NET - Powershell - VBScript
    Wednesday, September 16, 2009 7:09 AM