Query Active Directory for Inactive User Accounts

I need to modify an existing dsquery command that I am running in order to generate AD accounts that have a Days since last logon of 180 or 6 months.  I asked a similar question to where I got to this point and can be referenced here.  I believe it is only an additional parameter to be added, but not quite sure where. I was looking at including the -inactive 24 command, but it is giving me an error:

This is the current query I'm running:

dsquery * "dc=company,dc=com" -Filter "(&(objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2))" -limit 0 | dsget user -samid -upn -empid > C:\ADExport.txt


This is my previous question:

http://www.experts-exchange.com/Software/Server_Software/File_Servers/Active_Directory/Q_28232804.html
LVL 1
fireguy1125Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike KlineCommented:
You can do something like

dsquery user -inactive 24 | dsget user -disabled -samid -empid -upn

There are other tools but I know from the last question that you can't use them.

Thanks

Mike
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fireguy1125Author Commented:
Thanks again
0
Mike KlineCommented:
No problem glad you were able to get your reports.

Thanks

Mike
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Active Directory

From novice to tech pro — start learning today.