How to DSQuery enabled user who have been inactive for 90 days

Can some familiarwith DSQuery show how to run a query for
1. enabled users only
2. users who have been inactive for 90 or more days
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.

Matthew MillersCommented:
dsquery user -inactive <weeks>

I am not sure about showing if someone is enabled, you can show who is disabled by using -disabled
You may be able to do something with adfind
the inactive switch has always been hit and miss, you would be better off playing with oldcmp from joe
JoeyBugeyesAuthor Commented:
You're on the right track as far as what i'm looking for.  Now if only we can combine what you provided with the following to give me a list of enabled but inactive accounts.  

List all enabled user accounts: dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User)(!userAccountControl:1.2.840.113556.1.4.803:=2))" -limit 0

Thanks for your responses so far folks.
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Matthew MillersCommented:
You may be able to pipe the results out to dquery again:

dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User)(!
serAccountControl:1.2.840.113556.1.4.803:=2))" -limit 0 | dsquery user -inactive

You may want to pay attention to what Jay Jay has indicated, although this is for old computer accounts (the joeware util).

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
ahhh with the correct switches it will also work for user accounts :)
JoeyBugeyesAuthor Commented:
Nice.  I knew you could port DSQuery to a DSGet, but I didn't know you could port it to another dsquery.  Very nice!  Thanks everyone for contributing.
Were you able to make this work?  I am unable to pipe the dsquery results (Enabled Accounts) into the 2nd dsquery (Inactive Accounts).  Isn't there an easy way to query for Enabled AND Inactive Accounts?
rank master my ass he didn't take 5 seconds to test his solution
This is true, the above mentioned "Accepted Solution" Does NOT work!

Still looking for a working solution
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.