I made those changes and I found an article about scripting home
folders. I can not find the article here, but I have it booked marked at
home. The article said something about making sure the folders exist
before attempting to set the home folder. So I changed the code to
below.

I still need to touch the home folder path in order for the folder to
map.

Clients are win 2k and XP. Production Servers are win2k and win03.
My test domain is win 2003. The same effect happens on both test and
production.



'script to create home folders on new server
 'Rick Gasper
 'Copyright (c) 2003
 '8-8-2003 v2
 ' You may  use, modify, reproduce, and
 ' distribute this script in any way you find useful, provided that ' 
 ' you agree that the copyright owner above has no warranty,
obligations,
 ' or liability for such use.
 ''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
 'get users from ad
 
  Set Ulist = GetObject("LDAP://OU=test,ou=UserAccts,DC=home,DC=test";)
  Set objFSO = CreateObject("Scripting.FileSystemObject")
 
 'startloop
  For Each Usr In Ulist
     'set useracct variable so that the 


     useracct = usr.samaccountname

     strpath = "\\fs01\test$\" & usr.samaccountname
     
     Set objFolder = objFSO.CreateFolder(strpath)
     Set wshShell = WScript.CreateObject("Wscript.Shell")
 
    'create xcalcs scripts
 
     'struserperms =  useracct & ":rwc /y"
     stradminperms = " /G administrators:f " & useracct & ":f /y"
 
     strperms = "xcacls " & strpath & stradminperms 
     wshShell.Run strperms
     ' pause to see if permissions kick in.
     Wscript.Sleep 2000

     strpath = "\\server1\test$\" & usr.samaccountname
 
     usr.HomeDirectory = trim(strpath)
     usr.HomeDrive = "z"
     usr.SetInfo
    
 Next

Rick Gasper
Manager of Network Services
King's College
Wilkes-Barre PA 18706
Phone: 570-208-5845
Fax: 570-208-5989
[EMAIL PROTECTED]


-----Original Message-----
From: Roger Seielstad [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 08, 2003 7:02 AM
To: '[EMAIL PROTECTED]'
Subject: RE: [ActiveDir] changing home drive problem

Try making this change:
        usr.HomeDirectory = strpath
To
        usr.HomeDirectory = trim(strpath)
Not sure if that will do it, but I wonder if there isn't a trailing
character being stuck in there.

Also, move your objFSO = create... Outside the For...Next loop - that
object
only needs to be instantiated once. It also looks like the struser= is
an
orphan statement - it never gets used, and that's a fairly costly
statement
to execute for ever iteration. Comment it out and see if that speeds
things
up.


--------------------------------------------------------------
Roger D. Seielstad - MTS MCSE MS-MVP
Sr. Systems Administrator
Inovis Inc.


> -----Original Message-----
> From: Gasper, Rick [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, August 07, 2003 11:24 PM
> To: [EMAIL PROTECTED]
> Subject: [ActiveDir] changing home drive problem
> 
> 
> HI all,
> I am moving home folders to a new server. Since I have thousands of
> users I need to script this.
> The script works fine, however the new home folders don't map 
> until I go
> into aduc, make a change to the home folders (add a space to 
> the end of
> the path then delete it) ) and hit apply. I am working with 
> the connect
> to line.
> 
> Does anyone have any ideas why this is and more important: 
> how do I get
> around it? I really don't want to have to open 3000 accts.
> 
> The script is below:
> 
> '********************************************************
> 'script to create home folders on new server
> 'Rick Gasper
> 'Copyright (c) 2003
> '8-7-2003
> ' You may  use, modify, reproduce, and
> ' distribute this script in any way you find useful, provided that
> ' you agree that the copyright owner above has no warranty, 
> obligations,
> ' or liability for such use.
> ''''''''''''''''''''''''''''''''''''''''''''''''''''''
> 
> 'get users from ad
> 
> Set Ulist = GetObject("LDAP://OU=test,ou=User-Accts,DC=home,DC=test";)
> 
> 'startloop
> For Each Usr In Ulist
>     'set useracct variable so that the        
>     useracct = usr.samaccountname
>     struser = "WinNT://server1/" & usr.samaccountname & ",user"
>     strpath = "\\server1\staff$\" & usr.samaccountname
> 
>     usr.HomeDirectory = strpath
>     usr.HomeDrive = "S"
>     usr.SetInfo
> 
>    Set objFSO = CreateObject("Scripting.FileSystemObject")
>    Set objFolder = objFSO.CreateFolder(strpath)
> 
>    Set wshShell = WScript.CreateObject("Wscript.Shell")
> 
>    'create xcalcs scripts
> 
>     struserperms =  useracct & ":rwc /y"
>     stradminperms = " /G administrators:f " & useracct & ":f /y"
> 
>     strperms = "xcacls " & strpath & stradminperms 
>     wshShell.Run strperms
> 
> Next
> 
> 'end here
> Rick Gasper
> Manager of Network Services
> King's College
> Wilkes-Barre PA 18706
> Phone: 570-208-5845
> Fax: 570-208-5989
> [EMAIL PROTECTED]
> 
> 
> List info   : http://www.activedir.org/mail_list.htm
> List FAQ    : http://www.activedir.org/list_faq.htm
> List archive: 
> http://www.mail-archive.com/activedir%> 40mail.activedir.org/
> 
List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive:
http://www.mail-archive.com/activedir%40mail.activedir.org/
List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/

Reply via email to