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
JoeyBugeyesAsked:
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
0
Jay_Jay70Commented:
the inactive switch has always been hit and miss, you would be better off playing with oldcmp from joe
http://www.joeware.net/freetools/
0
JoeyBugeyesAuthor Commented:
Mattee76,
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.
0
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
 4

You may want to pay attention to what Jay Jay has indicated, although this is for old computer accounts (the joeware util).
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
Jay_Jay70Commented:
ahhh with the correct switches it will also work for user accounts :)
0
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.
0
ESParteeCommented:
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?
0
JD_PowersCommented:
rank master my ass he didn't take 5 seconds to test his solution
0
elchermansCommented:
This is true, the above mentioned "Accepted Solution" Does NOT work!

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