move home drive script question

From: Rick G (RickG_at_discussions.microsoft.com)
Date: 01/11/05


Date: Tue, 11 Jan 2005 08:21:09 -0800

HI all,

I need to move all the home directories to a new drive. everything works
except the new home drive doesn't map until I go to ADUC and add a space them
remove the space (Hitting OK afterward) to the path of the home drive.

My question is this: how do make the home drive settings with out touching
every account?

Just to be clear, the script works fine (well it did before I tried to clean
it up)
But to get the home directory to map I have to touch every account.

Script follows:

'script to move home folders to a new drive
'Rick Gasper
'Copyright (c) 2003
'1 - 2005
'
' 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=ad-test,ou=UserAccts,DC=mars,DC=uni")

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set wshShell = WScript.CreateObject("Wscript.Shell")
'startloop

For Each Usr In Ulist
        'set useracct variable so that the user name is converted to a string

        useracct = usr.samaccountname

        'create path For new home drive
        strpath = "\\FS01\testloc$\" & usr.samaccountname

        'get current home directory location

        currloc =usr.homedirectory

        'MsgBox currloc

'convert the acct name to a string
'get the lenght of the samaccountname
'get the lenght of the path of the current name

'this is done so tht I can pull the server name out of the home drive path

        accname = usr.samaccountname
        lenacctname =Len(accname)
        lenpath =Len(currloc)

'left lenthaccountname = +2

        netpath = Left(currloc, lenpath - (lenacctname +2))
        netpath = Right (netpath,Len(netpath) -6 )
        netpath = "e:" & netpath & "\" & usr.samaccountname
        
        objFSO.MoveFolder netpath , "e:\testloc\"
                
 
 
        ' create xcalcs scripts
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        struserperms = useracct & ":rc /y"
        stradminperms = " /G administrators:f " & useracct & ":rc /y"
 
        strperms = "xcacls " & strpath & stradminperms
        wshShell.Run strperms

        'set home folder
        usr.HomeDrive = "h"
        usr.SetInfo
        usr.HomeDirectory = trim(strpath)
        usr.setinfo
 
Next

msgbox "script done"

-- 
Rick G
Parts Unknown


Relevant Pages

  • Newbie: Why does SAMBA authentication fail?
    ... The problem is I can't map a drive to it from my Win XP box. ... ldap delete dn = No ...
    (comp.os.linux.misc)
  • Re: Drive maping help
    ... Dim objAccount, objDomain ... Set objDomain = GetObject ... Try this script, I think this is what you are asking for. ... As written, the above code will map a share whose name is, literally ...
    (microsoft.public.windows.server.scripting)
  • Re: troubleshoot a script
    ... I see you use the memberOf attribute. ... ' map appropriate drives. ... The part of the script that will not work for the 3 ...
    (microsoft.public.scripting.vbscript)
  • Re: Drive maping help
    ... Try this script, I think this is what you are asking for. ... Dim WSHNetwork ... it possible instead to use the Organizational Units name to setup the T: map? ... your script does not reference a groupname variable. ...
    (microsoft.public.windows.server.scripting)
  • Re: Limit desktop & start menu
    ... Create a login script that runs when users log into the TS, and map the R: ... persisitent "R" drive on the server itself and that may cure it. ...
    (microsoft.public.windows.terminal_services)