move home drive script question
From: Rick G (RickG_at_discussions.microsoft.com)
Date: 01/11/05
- Next message: RA: "Re: Network Time Recommendations"
- Previous message: Paul Liderman: "Cannot Add user proxy object"
- Next in thread: Chriss3 [MVP]: "Re: move home drive script question"
- Reply: Chriss3 [MVP]: "Re: move home drive script question"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: RA: "Re: Network Time Recommendations"
- Previous message: Paul Liderman: "Cannot Add user proxy object"
- Next in thread: Chriss3 [MVP]: "Re: move home drive script question"
- Reply: Chriss3 [MVP]: "Re: move home drive script question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|