Windows batch script to list / disable /delete dormant AD accounts

Does GPO / AD has feature or policy that could disable accounts that are inactive
for a certain number of days?

There are PowerShell scripts around but we are told to disable/remove Powershell
due to fileless attacks.

Ideally a windows batch or VB script.

I noticed  ' net user /domain  userid | find "Last logon"  '  has a date : if we could
iterate through all domain IDs & calculate based on this date, it will help.

There's oldcmp tool which seems to work for Win 2012 R2 AD but the csv output
it gives doesn't seem to provide any domain id in it or I've used it wrongly?
sunhuxAsked:
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.

sunhuxAuthor Commented:
net user /domain > file.txt
will list all the users in the AD

Next is I'll need a batch script to iterate through each of the id,
extract their last logon date/time & do a calculation.

For users that I wanted to be exempted, give me an option to
' find/V  list_of_users.txt  file.txt  >  file2.txt '
& we'll work based on file2.txt
Shaun VermaakTechnical SpecialistCommented:
Based on this and your other, almost duplicate question, it seems you want to do it the difficult way. Any particular reason for this?

I have written a utility designed for this will all your requirements here and in the other question but seems that you want to fiddle with NET.exe and VBS, not even Powershell...

What is your end goal?

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
austin minorCommented:
sunhuxAuthor Commented:
Ok, was looking for something that can be placed in a scheduler:
missed that Shaun's utility could be scheduled.

Am a die-hard of basic scripts as they are not going to be
end-of-life with newer versions of AD/Windows.

Thanks.
Shaun VermaakTechnical SpecialistCommented:
Ok, was looking for something that can be placed in a scheduler:
missed that Shaun's utility could be scheduled.
Yes

end-of-life with newer versions of AD/Windows.
Technically VBS is end-of-life, just not end-of-support.
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
Powershell

From novice to tech pro — start learning today.