Link to home
Create AccountLog in
Active Directory

Active Directory

--

Questions

--

Followers

Top Experts

Avatar of teodor76
teodor76

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?

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


SOLUTION
Avatar of Joseph DalyJoseph Daly🇺🇸

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

Avatar of Chris DentChris Dent🇬🇧


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

Avatar of Joseph DalyJoseph Daly🇺🇸

In that example above the {startnode} is replaced by the distinguished name of the OU where the users are.

Avatar of teodor76teodor76

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?

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


ASKER CERTIFIED SOLUTION
Avatar of Chris DentChris Dent🇬🇧

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.

Avatar of Joseph DalyJoseph Daly🇺🇸

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




Set objOU = GetObject("LDAP://OU=somewhere,OU=somewhereelse,DC=yourdomain,DC=com")
 
 on tob,I have a one OU named XX,its further down,there are five OU structure named Xa,Xb,Xc,Xd,Xe..I would like to change only users' profile and home paths in the named Xd OU..how can I write ldap Query?
(LDAP://OU=XX,OU=Xd,DC=yourdomain,DC=com) or
(LDAP://OU=Xd,,DC=yourdomain,DC=com)

 

 


Avatar of Chris DentChris Dent🇬🇧


That would change this line to:

Set objOU = GetObject("LDAP://OU=Xd,OU=XX,DC=yourdomain,DC=com")

It goes in reverse order, so domain.com/xx/xd in AD users and computers will become the above.

Chris

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


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
 

Avatar of Joseph DalyJoseph Daly🇺🇸

If you dont want to do it by command line you could probably also accomplish this fairly easily using admodify.,net.

http://technet.microsoft.com/en-us/library/aa996216(EXCHG.65).aspx

download here
http://admodify.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=6065

Avatar of Chris DentChris Dent🇬🇧


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.

Chris

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


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
Active Directory

Active Directory

--

Questions

--

Followers

Top Experts

Active Directory (AD) is a Microsoft brand for identity-related capabilities. In the on-premises world, Windows Server AD provides a set of identity capabilities and services, and is hugely popular (88% of Fortune 1000 and 95% of enterprises use AD). This topic includes all things Active Directory including DNS, Group Policy, DFS, troubleshooting, ADFS, and all other topics under the Microsoft AD and identity umbrella.