PowerShell - Export to CSV File - Active Directory RRS feed

  • Question

  • Hi Guys,

    I am looking for a pipped command or simple script to export AD groups and the canonical name of a user to csv file for backing up purposes. Also it would be ideal to have a script to do this for number of users at once and this creating separate csv file for each user.  Thank you very much and looking for some lovely ideas.  

    Thursday, May 26, 2016 3:13 PM


  • Use Export-Csv Cmdlet instead of Out-File
    Out-File will just output string to the csv file.

    Using this '-Properties *' u r getting all properties but u just need CanonicalName.
    Instead Use this -Properties CanonicalName.

    Get-ADUser $CurrentUser -Properties CanonicalName | 
                                                  Select-Object CanonicalName | 
                                                            Export-Csv C:\Test\User.csv

    Wednesday, June 15, 2016 11:03 AM

All replies