DSMOD

W

Wade Rocco

Hey All,

I'm looking for a way to bulk change the 'Home Folder' attribute of a user
account to a blank local path. I did some research and I think I can use
dsmod to accomplish this, I'm just uncertain of how the syntax should be.

I've been using:

dsquery user "OU=test,DC=domain,DC=com" | dsmod user -hmdir
dsquery user "OU=test,DC=domain,DC=com" | dsmod user -hmdrv

This will allow me to change the existing value for the UNC for the Home
Directory as well as the Drive letter, but I haven't been able to figure out
how to set it to a blank local path.

Any help is greatly appreciated!!!


Thanks,

Wade
 
L

Laura E. Hunter [MVP]

If I'm understanding you correctly, you're trying to set homeDirectory and
homeDrive to blank values, yes?

I'm a bigger fan of adfind and admod from www.joeware.net; they're a lot
more flexible in most cases than the built-in ds* stuff.

To remove these two values on a single user object:

admod -b "cn=Joe User,ou=Finance,dc=company,dc=com" homeDirectory:-:
homeDrive:-:

To remove these two values on all user objects that have these values
configured within a single ou:

adfind -default -rb "ou=Finance" -f
"(&(objectcategory=user)(objectclass=user)(homeDirectory=*)(homeDrive=*))" -dsq
| admod homeDirectory:-: homeDrive:-:

-default means "Use the default domain value as a base, like
dc=company,dc=com."
-rb is your relative base, so specifying -default -rb "ou=Finance" would
search for objects in "ou=Finance,dc=company,dc=com". (It's just a shortcut
to save typing.) If you eliminate -rb "blah" and just use -default, you're
running the query against your entire domain.
-f
"(&(objectcategory=user)(objectclass=user)(homeDirectory=*)(homeDrive=*))"
is an LDAP filter that will return only the user objects that
have -something- configured for those two attributes.
-dsq essentially means "Put the adfind output into a useful format for me to
pipe it into something like admod."

If you'll be modifying more than 10 objects, you'll also need to use
either -safety x, where x is the number of objects you want to modify,
or -unsafe for "Go ahead and modify everything you find." By default, admod
will complain and quit if you try to modify more than 10 objects at a time;
it's a sanity-checking thing to prevent you from doing something really
really horrible to your AD that you didn't mean to.

Adfind and admod are your friends: go download them and thank me later. :)

HTH
 
J

Jerold Schulman

Hey All,

I'm looking for a way to bulk change the 'Home Folder' attribute of a user
account to a blank local path. I did some research and I think I can use
dsmod to accomplish this, I'm just uncertain of how the syntax should be.

I've been using:

dsquery user "OU=test,DC=domain,DC=com" | dsmod user -hmdir
dsquery user "OU=test,DC=domain,DC=com" | dsmod user -hmdrv

This will allow me to change the existing value for the UNC for the Home
Directory as well as the Drive letter, but I haven't been able to figure out
how to set it to a blank local path.

Any help is greatly appreciated!!!


Thanks,

Wade

dsquery user "OU=test,DC=domain,DC=com" | dsmod user -hmdrv ""
dsquery user "OU=test,DC=domain,DC=com" | dsmod user -hmdir ""

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 
W

Wade Rocco

Thanks for your response, Jerold. I've tried that and it seems to crash. I
get one of those "an error has been encountered..blah blah". I'm running a
2k domain, and issuing this from a XP workstation, not sure if that would
create any problems.
 
J

Jerold Schulman

In that case, use adfind / admod"

Tip 5898 » Freeware ADFind in the 'Tips & Tricks' at http://www.jsifaq.com
Tip 8233 » AdMod freeware

Run the following batch:

@echo off
setlocal
for /f "Tokens=*" %%u in ('adfind -dsq -b "OU=test,DC=domain,DC=com" -f "&(objectcategory=person)"') do (
ADMOD -b %%u "homeDirectory:-"
ADMOD -b %%u "homeDrive:-"
)
endlocal







Thanks for your response, Jerold. I've tried that and it seems to crash. I
get one of those "an error has been encountered..blah blah". I'm running a
2k domain, and issuing this from a XP workstation, not sure if that would
create any problems.

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 
W

Wade Rocco

Thanks a bunch, Jerold and Laura!! ADFIND/MOD worked perfectly, this is an
excellent tool. I can't wait to experiment more with it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top