Search The Web

Friday, January 25, 2013

Using Powershell to get export of AD users


Using Powershell to get export of AD users


Firstly, you need to import the Power Shell  command tools for AD

import-module activedirectory

Once this has been done, then run this command:

Get-ADUser -filter * -searchbase "OU=blah,OU=blah, ,DC=contoso,DC=microsoft,DC=com" -Properties given
Name, sn, sAMAccountname | select-object givenName,sn,samaccountname,distinguishedname | export-csv accountnames.csv

You can edit this for different results as required.