| Author |
Message |
Rick G
Guest
|
Posted:
Tue Jan 11, 2005 10:21 pm Post subject:
move home drive script question |
|
|
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 |
|
| Back to top |
|
 |
Chriss3 [MVP]
Guest
|
Posted:
Tue Jan 11, 2005 11:00 pm Post subject:
Re: move home drive script question |
|
|
Hello Rick,
Try use PutEx ADS_PROPERTY_UPDATE.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/iads_putex.asp?frame=true
--
Regards
Christoffer Andersson
Microsoft MVP - Directory Services
No email replies please - reply in the newsgroup
------------------------------------------------
http://www.chrisse.se - Active Directory Tips
"Rick G" <RickG@discussions.microsoft.com> skrev i meddelandet
news:4A7AE928-EB92-445A-B8A0-58CAB7AFA9BC@microsoft.com...
| Quote: | 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 |
|
|
| Back to top |
|
 |
Rick G
Guest
|
Posted:
Wed Jan 12, 2005 7:59 pm Post subject:
Re: move home drive script question |
|
|
I did this instead and it worked. Thanks for the idea, it led me to the answer:
usr.Put "homeDirectory", strpath
usr.setinfo
"Chriss3 [MVP]" wrote:
| Quote: | Hello Rick,
Try use PutEx ADS_PROPERTY_UPDATE.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/iads_putex.asp?frame=true
--
Regards
Christoffer Andersson
Microsoft MVP - Directory Services
No email replies please - reply in the newsgroup
------------------------------------------------
http://www.chrisse.se - Active Directory Tips
"Rick G" <RickG@discussions.microsoft.com> skrev i meddelandet
news:4A7AE928-EB92-445A-B8A0-58CAB7AFA9BC@microsoft.com...
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
|
|
|
| Back to top |
|
 |
|
|
|
|