Solved

Change profile and home folder path with a script

Posted on 2004-08-19
4
760 Views
Last Modified: 2010-08-05
What I want to do:
Change the profile path and the home folder path for a specific OU with a vbs script.



Here is a script I`ve found that maybe can be used:

Set objOU = GetObject _
("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

objUser.Put "profilePath", "\\sea-dc-01\Profiles\myerken"
objUser.Put "scriptPath", "logon.bat"
objUser.Put "homeDirectory", "\\sea-dc-01\HomeFolders\myerken"
objUser.Put "homeDrive", "H"

objUser.SetInfo


When I run this script from a domain controller I get this error error:
Line: 1
Char: 1
Error: A referral was returned from the server
Code: 8007202B
Source: (null)


Anyone that knows what is wrong?


Eventually got a better/easier script for the task I want to perform?
0
Comment
Question by:jering
  • 2
4 Comments
 
LVL 31

Expert Comment

by:merowinger
ID: 11840325
hi,
Check the spelling of your LDAP objects.  Look for clues particularly the Line: number.  In this case it Char: 1 is not to blame.  When none of the line can execute, the error gets charged to the first character. In the case of runtime errors if you are desperate then use this work around.  Add this line: On Error Resume Next

mero
0
 

Author Comment

by:jering
ID: 11840844
I made it work using this:

!START!
Set ou = Getobject("LDAP://OU=test,ou=BTOTEST,ou=Skoler,dc=elev,dc=steinkjer,dc=local")

For each obj in ou

obj.profilePath = "\\sea-dc-01\%username%" & obj.cn
obj.scriptPath = "logon.vbs"
obj.homeDirectory = "\\sea-dc-01\%username%-profile" & obj.cn
obj.homeDrive = "H:"
obj.setinfo

Next

MsgBox "OU update complete"
!END!

It works fine, except that I get this path:
\\sea-dc-01\%username%profil test

So the %username% works, but it adds its code before the username. Any suggestions how to solve this?
0
 
LVL 5

Accepted Solution

by:
jmacmicking earned 125 total points
ID: 11841266
You're adding the username with "& obj.cn" -- using %username% is redundant.  If you change the following two lines I think you'll accomplish what you're looking for:

obj.profilePath = "\\sea-dc-01\" & obj.cn
obj.homeDirectory = "\\sea-dc-01\" & obj.cn & "-profile"

This will make the user's profile folder match the user's common-Name attribute; their homeDirectory will be their common-Name, a dash and then the word profile.  For example, assume the person's name is John Doe, their common-Name is Doe John, then their directories would be:
  Home Directory :  \\sea-dc-01\Doe John
  Profile              :  \\sea-dc-01\Doe John-profile

If this isn't the format you wanted please post they way you would like the directory names to appear.  
0
 

Author Comment

by:jering
ID: 11843048
Thank you VERY much! Now it worked excactly the way I wanted!
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Disk size support for operating systems 12 533
Change port for terminal servers (2000 and 2003) 3 158
windows 2000 - Enable wifi 7 142
Connect Windows 8 VPN to ISA Server 2000 VPN 5 122
NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question