Link to home
Start Free TrialLog in
Avatar of Sid_F
Sid_F

asked on

Export list of disabled users AD

Can any one tell me the exact command to export disabled users to a file using csvde thanks.
Avatar of Frosty555
Frosty555
Flag of Canada image

To get a list of disabled users:

Import-Module ActiveDirectory
Get-ADUser -Filter {Enabled -eq $false}

To export it to a CSV file you would use the Export-CSV command in Powershell, e.g.

Get-ADUser -Filter {Enabled -eq $false} | Export-Csv "C:\some\folder\somefile.csv"
Avatar of Sid_F
Sid_F

ASKER

I need to do it via csvde
Avatar of arnold
You can try using -r to specify the enabled=yes.

https://technet.microsoft.com/en-us/library/cc757853(v=ws.10).aspx

Let's start from the begining, what is it you want to achieve at the end? Do you have the option to delete disabled accounts?

Look at the ldap filter list from http://social.technet.microsoft.com/wiki/contents/articles/5392.active-directory-ldap-syntax-filters.aspx they have a reference on how to identify disabled accounts, you need to change the filter to exclude them.  
Search for all disabled user accounts or something like that, three four pages down.
Avatar of Sid_F

ASKER

Ok found out the detail from http://www.computerperformance.co.uk/Logon/Logon_CSVDE_switches.htm

csvde -f c:\AllDisabled.csv -r "(|(useraccountcontrol=514)(useraccountcontrol=546)(useraccountcontrol=66050))" -l "DN, objectclass, objectcategory, sn, givenName, sAMAccountName, useraccountcontrol"

This will output all disabled users in AD
ASKER CERTIFIED SOLUTION
Avatar of arnold
arnold
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial