Skip to main content
0 online

Active Directory

thefunkyfresh by thefunkyfreshFounder · Jul 12, 2005 · 108 views

My last cry for help got no response so hopefully somebody knows this one. We need to clean up the Active Directory here where I work, it's a student body so the user base is constantly changing. I want to disable all user accounts that have been inactive for the past 9 weeks. I found the following script online that should work, but I don't know how to run it. I tried it from the start... run dialog box and also from a command prompt but it didn't seem to do anything. Here's the script:

c:\> dsquery user -inactive 9 | dsmod user -disabled yes

What (and please be VERY specific) do I need to do to either get this script to work or get it done another way? Hope somebody can help, thanks!

To contribute to the discussion, please log in.

25 Comments

iwz #7 iwz
iwz #7.1 iwz

so it seems like, if all of your domain controllers are running 2003, then you should switch to 2003 server level.

if you have older controllers in the domain, then you should look into using this tool instead of dsquery

http://www.joeware.net/win/free/tools/oldcmp.htm

iwz #6 iwz
iwz #5 iwz

If you don't have Win2k3 servers, then you can't use the -inactive flag, so you may want to try this tool instead of dsquery

http://www.joeware.net/win/free/tools/oldcmp.htm

iwz #5.1 iwz

actually, i would try this first, because it's ready to go. you have to copy the .bat file here

http://www.jsifaq.com/SUBQ/tip8200/rh8260.htm

and the one here as well

http://www.jsifaq.com/subq/tip8000/rh8079.htm

thefunkyfresh #5.1.1 thefunkyfreshFounder

cool, i'll try this one tomorrow

iwz #4 iwz
iwz #3 iwz

when you run that from a command prompt, what output do you get?

and you know enough not to type the "c:\>" part, right?

i mean, you should, you've got like a doctorate in Computer Science or something

yay #3.1 yayOG 2004

maybe thats why he put it in programming forum, to confuse everyone

yay #3.2 yayOG 2004

hi lets dance

thefunkyfresh #3.3 thefunkyfreshFounder

i hate you ian... yes i know enough not to type the c:\>

anyway, here's the output:

dsquery failed:The parameter is incorrect.:Windows could not run this query because you are connected to a domain that does not support this query. type dsquery /? for help.
dsmod failed:`Target object for this command' is missing.
type dsmod /? for help.

i guess it looks like I have to install them? I'm wondering from where though

iwz #3.3.1 iwz

well, you have both commands. the problem is something with the domain you're connected to, it looks like

iwz #3.3.2 iwz
iwz #3.3.2.1 iwz

do you have a Win2k3 domain? If yes, are you running at 2000 mixed mode?

thefunkyfresh thefunkyfreshFounder

yeah i saw that forum earlier. We have a w2k3 domain, but i'm trying to find out if it could be operating in mixed mode. trying to figure out how

iwz iwz

"To convert, open Active Directory Users and Computers from the Administrative Tools menu. Right-click the domain and choose Properties. On the General tab, click Change Mode. Click Yes, then OK. "

thefunkyfresh thefunkyfreshFounder

found out we are in mixed mode. i don't see a "change mode" button in there. but anyway, I don't know if there would be repercussions to changing it over

yay #2 yayOG 2004

It looks like 2003, is this what you are running?
Do the commands even exist on that system?

They are not scripts, they are actual programs
dsquery and dsmod are programs for supporting AD

Its just piping one command output to the right command

thefunkyfresh #2.1 thefunkyfreshFounder

I think they exist... I'm not really sure though. If I go to the command prompt and type in dsquery /? it gives me a whole bunch of info. However, I did a search on the drive and didn't find dsquery.exe or dsmod.exe.

I did a search online and found a site where I could download dsquery.dll
What do I need to do?

yay #2.1.1 yayOG 2004

in your cmd prompt run
dsquery user -inactive 9

does it give youa list of users?

yay #2.2 yayOG 2004

basically it says
for every user 9 months inactive, disable the user with dsmod command
pipe the list of "dsquery user -inactive 9" to "dsmod user -disabled yes"

so a couple things.

if its 2003 specific, and dont have 2003 you may be out of luck
if you do, then you need to install your resource disks

thefunkyfresh #2.2.1 thefunkyfreshFounder

we do have server 2003... i'll look for those disks i guess

yay #2.2.1.1 yayOG 2004

you have the commands, its just the way your executing is wrong or something is wrong

try to execute one command at a time

specialk #1 specialkOG 2003

My husband might be able to help....if you wanna email him and ask him (he's really cool, he wouldn't mind), let me know.

thefunkyfresh #1.1 thefunkyfreshFounder

let's see if ezabel can bail me out first, but thanks :)

Welcome Back to eZabel

It's been a while. Here's what's new.

eZabel Lore

A complete history of our community — stats, Hall of Fame, legendary threads, and more.

View the Lore →

Curator Commentary

Look for the blue speech bubbles on threads, profiles, and news — notes and context from iwz.

Everything Preserved

All 225,969 pieces of content from 2000–2014 are here — forums, messages, journals, photos, polls, and events.