Avatar of fireguy1125
fireguy1125 asked on

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:

https://www.experts-exchange.com/Software/Server_Software/File_Servers/Active_Directory/Q_28232804.html
Active DirectoryWindows Server 2008

Avatar of undefined
Last Comment
Mike Kline

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Mike Kline

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
fireguy1125

Thanks again
Mike Kline

No problem glad you were able to get your reports.

Thanks

Mike
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck