How to generate and export AD enabled users to CSV using PowerShell scripts

The following is a comparison between obtaining an enabled AD user report with Windows PowerShell and ADManager Plus.

Windows PowerShell

Steps to obtain enabled users report using PowerShell using get-aduser cmdlet:

  • Identify the domain from which you want to retrieve the report.
  • Identify the LDAP attributes you need to fetch the report.
  • Identify the primary DC to retrieve the report.
  • Compile the script 
  • Execute it in Windows PowerShell.
  • The report will be exported in the given format.
  • To obtain the report in a different format, modify the script accordingly to the needs of the user.

Sample Windows PowerShell script:

 Copied
import-module activedirectory Get-ADUser-LDAPFilter
"(&(objectCategory=person)
(objectClass=user)
(!userAccountControl:1.2.840.113556.1.4.803:=2))"
-Properties sAMAccountName,
givenName, sn, enabled |
Select sAMAccountName,
givenName, sn, enabled |
Export-Csv -Path
c:\Scripts\Users.csv -NoTypeInformation
Click to copy entire script

ADManager Plus

To obtain the report,

  • Select Disabled Users from User reports section.  
  • Select Domain and OU. Click Generate. 
  • Select Export as to export the report in any of the preferred formats (CSV, PDF, HTML, CSVDE and XLSX).

Screenshot

Export enabled Active Directory users to CSV using ADManager Plus
 

» Start 30-day Free Trial

Following are the limitations to obtain report of enabled AD user accounts using native tools like Windows PowerShell:

  • We can run this script only from the computers which has Active Directory Domain Services role.
  • Adding even minor details to the report—such as adding additional attributes—require scripts to be modified and executed again, which is time-consuming.
  • Exporting a report in a specific format requires a script to be modified accordingly, which increases the complexity of the scripts.
  • Troubleshooting is not easy in case of errors.

Using PowerShell scripting, each attribute which has to be displayed in the report should be included in the cmdlets in contrast to using the 'Add/Remove Columns' feature of ADManager Plus .'Enabled Users' is a readily available report in ADManager Plus which can be exported in any of the available formats.

  • Embark on your script-free AD management, reporting, and automation journey with ADManager Plus.
  •  
  • By clicking 'Start your free trial now', you agree to processing of personal data according to the Privacy Policy.
  • Thanks
  • Your download should begin automatically in 15 seconds. If not, click here to download manually.

Related Powershell How-to Guides:

Email Download Link