
Select -Property SamAccountName,Mail,Department,displayName,mobile |Įxport-CSV "C:\ADUsers.csv" -NoTypeInformation -Encoding UTF8Īlong with normal attributes, you can also add the Extended Properties like AccountLockoutTime, Enabled, LockedOut (refer this article: Get-ADUser Default and Extended Properties to know more supported extended AD attributes). If you want to add the attributes displayName and mobile with this script, you can simply add these attributes as comma separated values. You can add any extra attribute that supported in Active Directory in property list. Get-ADUser -Filter * -SearchBase "OU=TestOU,DC=TestDomain,DC=Local" -Properties * |Įxport-CSV "C:\TestOUUsers.csv" -NoTypeInformation -Encoding UTF8 The following powershell script select all the AD users from the Organization Unit ‘TestOU’ and export it to CSV file. We can set target OU scope by using the parameter SearchBase.

Select -Property SamAccountName,Mail,Department |Įxport-CSV "C:\AllADUsers.csv" -NoTypeInformation -Encoding UTF8 The following powershell script exports the selected properties of all Active Directory users to CSV file. You can select any user attribute that supported in Active Directory using Get-ADUser cmdlet and it also supports Extended Properties like AccountLockoutTime, Enabled,LockedOut (refer this article: Get-ADUser Default and Extended Properties to know more supported AD attributes). By using these filter we can generate any kind of Active Directory Reports. Get-ADUser cmdlet supports SQL like filter and LDAP filter to filter AD Users.

We can generate and export Active Directory users report to CSV file using Powershell cmdlets Get-ADUser and Export-CSV.
