The first thing you to do is open a PowerShell session either locally on a machine running the AD DS role (like a Domain Controller) or install the Remote Server Admin Tools (RSAT) so that the Active Directory module is available.

When it comes to exporting users you have a lot of options for the information you want exported. User accounts have a lot of associated attributes (which you can see if you go to Extension -> Attributes in Active Directory Admin Center).

Another way to see the attributes you have available to export is to run the following command within your PowerShell window:

Export All AD Users by Name to CSV

This command will export all of the user accounts in your domain to a CSV by their name. What this means is that the CSV file will contain a single column list of every account’s First, Middle, and Last name.

The ‘export-csv -path c:\temp\userexport.csv’ after the pipe (the | character) is what exports the data to CSV. If you drop that section of the command it’ll simply print the results to your PowerShell window.

Export All AD Users by Name and LastLogonDate

If you want a list of every account’s name and the last date the account authenticated with the domain then you can run the command:

This will export all accounts in your domain to a CSV sheet with the First, Middle, and Last name in the first column and LastLogonDate in the second column.

If you want to export more attributes you just need to add them the Select-Object section of the command separated by a comma. For example:

Export All AD Users by Multiple Attributes

Export All AD Users Email Addresses

Export All AD Users from Specific OU (Organizational Unit)

Before you run this command you need to find the distinguishedName attribute of your OU. You find this by opening the properties of the OU in Active Directory Admin Center and going to Extensions -> Attribute Editor.

At this point I’m betting you’re getting the gist of it. Like I said, pretty easy!