Change profile and home folder paths on the all the users in AD
I would like to change the profile path and the home folder path for all the users a specific OU with a vbs script..there are 600 users on AD.what is the better/easier script for the task I want to perform?
If they're all in the same OU are you aware that you can do this in AD Users and Computer?
Select them all (in AD Users and Computers), then Open the Properties then explicitly change those two (and only those two) by ticking the box beside them and setting the new value.
Of course we can do this in VbScript if you're after it doing something a bit more complex.
Chris
Joseph Daly
In that example above the {startnode} is replaced by the distinguished name of the OU where the users are.
teodor76
ASKER
thank you for your information.
I have selected a few test users in AD and then click properties and I typed a new user profile path and home
profile path= \\serverX\profile\%username%
home path=\\serverX\home\%username% because username is changing for every user..I gets error when I type "%username%"
Also 1 would like to try dsquery..links that you type is not working.could you please write dsquery as detailed? what will I write the username place for every seperate user?
I dont understand what this means
"Also 1 would like to try dsquery..links that you type is not working.could you please write dsquery as detailed? what will I write the username place for every seperate user?"
I just tested the links and both of them are live.
The special token $username$ (case insensitive) may be used to place the
SAM account name in the value of -webpg, -profile, -hmdir, and
-email parameter.
For example, if the target user DN is
CN=Jane Doe,CN=users,CN=microsoft,CN=com and the SAM account name
attribute is "janed," the -hmdir parameter can have the following
substitution:
-hmdir \users\$username$\home
The value of the -hmdir parameter is modified to the following value:
- hmdir \users\janed\home
teodor76
ASKER
Set objOU = GetObject("LDAP://OU=somewhere,OU=somewhereelse,DC=yourdomain,DC=com")
I get the following error when I run the .vbs file named profile.vbs by clicking on the domain controller
Set objOU = GetObject("LDAP://OU=Xd,OU=XX,DC=microsoft,DC=com")
objOU.Filter = Array("user")
For Each objUser in objOU
objUser.Put "homeDirectory", "\\dc-srv-01\home$\" & objUser.Get("sAMAccountName")
objUser.Put "profilePath", "\\dc-srv-01\profile$\" & objUser.Get("sAMAccountName")
objUser.SetInfo
Next
the error> Line=2,Char=1, Error=A referral was returned from the server.Code=8007202B,Source=null
Joseph Daly
If you dont want to do it by command line you could probably also accomplish this fairly easily using admodify.,net.
That would suggest the path supplied is invalid (doesn't exist on the server you made the request to).
Trying to think of the easiest way to check the path...
If you have the Support Tools installed, open up ADSIEdit.msc (Start, Run). Then browse to the OU you want to make the changes to, open up the Properties and take a look at the "distinguishedName" attribute. The value there is the one we want to use in the script.
yes you are right..I made a mistake.I have adjusted the distinguishedName for OUs from ADSIEdit.msc
first, 1 tried Chris's vbscript and it didnt give me a error but nothing happened when 1 click on dc..no error,no message,no change
second,I tried xxdcmast's solution dsquery user "OU=Xd,OU=XX,DC=microsoft,DC=com" |dsmod user -profile \\ds-srv-01\profile$\$username$ -hmdrv \\dc-srv-01\home$\$username$
it works wihthout errors and it returned the following changes for each user on AD
profile=\\ds-srv01\profiles$\$username$ (it didnt give me usernames in that OUservername=true,profiles$=true but no username)
home=it didnt changed. why didnt it change? also it doesnt available drive name=H
it will be in this way
home folder=
connect=drive letter to=\\ds-srv01\profiles$\user's name
If they're all in the same OU are you aware that you can do this in AD Users and Computer?
Select them all (in AD Users and Computers), then Open the Properties then explicitly change those two (and only those two) by ticking the box beside them and setting the new value.
Of course we can do this in VbScript if you're after it doing something a bit more complex.
Chris