To extract all the users in the OU with the Password never expires details, we can user Dsquery or CSVDE commands
Use the blow command to find and export users with Password never expires in Active Directory
Dsquery command
dsquery user “OU=Test,DC=test,DC=com” -limit 0 | dsget user -pwdneverexpires >c:tempUsers.txt
dsquery user “OU=Test,DC=test,DC=com” –o rdn -limit 0> c:tempUsers1.txt
Collect this two file (Users1.txt & Users.txt) date’s and merge to a single excel file
Users1.txt – Have the users name from test OU
Users2.txt – Have the pwdneverexpires details like Yes or No
CSVDE command
This command only extracts the user details who has the option Password never expires in the Test OU
syntex:
csvde -f “file path” -d ” OU LDAP path” -r “(&(objectClass=user)(objectCategory=person)( userAccountControl= 66048
))” -l “DN,cn,givenname,sn,displayName”
Example:
csvde -f C:Tempuser.csv -d “OU=test,DC=test,DC=com” -r “(&(objectClass=user)(objectCategory=person)( userAccountControl= 66048
))” -l “DN,cn,givenname,sn,displayName”
Related Articles
Force the Active Directory replication between two domain controllers in low bandwidth sites
Force replication with all of its replication partners
How to check Active directory replication for multiple Domain Controllers