Get Active Directory Disabled / Enabled Users using PowerShell
Active Directory Get-AdUser retrieves a default set of user properties. Using the Identity parameter, you can specify the active directory user to get its properties
Get-AdUser is used to get one or more active directory objects or perform a search to get specific users.
Note that you have to install the PowerShell AD module before using the command. If you do not know how to do it see here ->
How to use
First of all, open PowerShell from Start – PowerShell and run it as an administrator. I recommend you to use PowerShell ISE witch you can save your script.
Get-AdUser:
Get-ADUser -Identity Jim -Properties *
the above command, Get-AdUser gets all properties of SAMAccountName user Jim , specified by the Identity parameter.
Export All Enabled Ad users to CSV file
Get-ADUser -LDAPFilter ‘(!userAccountControl:1.2.840.113556.1.4.803:=2)’|Export-CSV “C:\Temp\EnabUsers.CSV” –NoTypeInformation
The above command Will Give you all the Enabled Users on your Active Directory. Do not forget the pipe | symbol ! Finally search to the C:\Temp\EnabUsers to find the csv
Export All Disabled Ad users to CSV file
Get-ADUser -Filter {(Enabled -eq $False)} -ResultPageSize 2000-ResultSetSize $null -Properties Name, LastLogon | Export-CSV “C:\Temp\DisabUsers.CSV” –NoTypeInformation
The above command Will Give you all the Disabled Users with their last logon on your Active Directory. Finally search to the C:\Temp\DisabUsers to find the csv
Good Luck !