How to use DSQUERY to get a list of the active users.

MichaelK2 used Ask the Experts™
I am wanting to just get the active users in a domain i.e  the ones who have logged on in the last week.
I have run from the command: dsquery user - active 1 >>c:\active.txt but it does not seem to like the word active. Is DSQUERY only to find out inactive details
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Systems engineer
Top Expert 2008
You have the possibility to query for inactive users that hasn't logged on the last weeks by using -inactive parameter, but there's not a -active parameter for the query you want.
Chris DentPowerShell Developer
Top Expert 2010

DsQuery is out of the question for this.

The only replicated attribute which records the last logon is "lastLogonTimeStamp", that value can be up to 14 days out of date so is no use for discovering those logged on in the last week.

That means you need to execute something which can check the "lastLogon" attribute on every DC. That one is accurate, but not replicated, hence the need to check every DC.

The version here would be a good start if you're sticking with VbScript (suggested by the zones you posted the question in):



I feel it was only good and not excellent.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial