Share via


Active Directory User - Export Attributes to CSV

Question

Friday, October 5, 2018 3:33 PM

I am trying to figure out how I can see the list of different AD User attributes.... Select what I want to display, and then export to CSV.

Some of the necessary attributes will be Username, Display Name, Email Address, User Creation Date, Enabled/Disabled?

Any help would be appreciated.... I am a complete Powershell Newbie!!

Brian Modlin

All replies (6)

Friday, October 5, 2018 3:39 PM

help Get-AdUser -online

Follow the examples.

\(ツ)_/


Monday, October 8, 2018 3:22 AM

When I run the following powershell command it lists the users, but ALL fields in the CSV are empty except for the ENABLED and SamAccount fields:

Get-ADUser -SearchBase "ou=_departments,ou=*sas,dc=abc,dc=local" -Filter '*' |  select DisplayName, SamAccountName, Company, Created, LastLogonDate, OfficePhone, EmailAddress, Enabled | Export-Csv c:\csv\ADUsers.csv

What am I doing wrong?

Brian Modlin


Monday, October 8, 2018 5:26 AM

try -Properties * or -Properties DisplayName, SamAccountName, Company, Created, LastLogonDate, OfficePhone, EmailAddress, Enabled

Get-ADUser -SearchBase "ou=_departments,ou=*sas,dc=abc,dc=local" -Filter '*' -Properties *|  select DisplayName, SamAccountName, Company, Created, LastLogonDate, OfficePhone, EmailAddress, Enabled |Export-Csv .\s.csv

Or

Get-ADUser -SearchBase "ou=_departments,ou=*sas,dc=abc,dc=local" -Filter '*' -Properties DisplayName, SamAccountName, Company, Created, LastLogonDate, OfficePhone, EmailAddress, Enabled |  select DisplayName, SamAccountName, Company, Created, LastLogonDate, OfficePhone, EmailAddress, Enabled |Export-Csv .\s.csv

Monday, October 8, 2018 5:27 AM | 1 vote

You need to add the properties of the fields you wish to extract, that are not included in the default output.

Get-ADUser -SearchBase "ou=_departments,ou=*sas,dc=abc,dc=local" -Filter * -Properties DisplayName, Company, Created, LastLogonDate, OfficePhone, EmailAddress | 
    Select-Object DisplayName, SamAccountName, Company, Created, LastLogonDate, OfficePhone, EmailAddress, Enabled |
    Export-Csv c:\csv\ADUsers.csv

Friday, October 26, 2018 8:50 AM

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.

Best Regards,

Lee

Just do it.


Monday, November 5, 2018 9:29 AM

Hi,

As this thread has been quiet for a while, we will mark it as ‘Answered’ as the information provided should be helpful. If you need further help, please feel free to reply this post directly so we will be notified to follow it up. You can also choose to unmark the answer as you wish.

Best Regards,

Lee

Just do it.