Hi,
I thought i'd post my updated script to move the directories with the addition of Howard Bullock's Win32Admin.dll function. I havnt run it in a live system yet but have done some testing and it all seems to be working.
code:
Break On Cls
;Directory and Source Variables
$SourceDir="D:\Sys\Users\" ; Local source path of user directories
$MappedDrive="E:\" ; Drive mapped to user share at other location
$SourceServer="\\CONGRESS-SVR1\" ; Server where original user dir is held
$DestServer="\\SVRCONGRESS\" ; Server where new user dir is to be copied
$DestSharePath="D:\Users\" ; directory on destination server to the path of the user directory
$PDC="SVRSTOKE" ; Primary Domain Controller
$HomeDirDrive="U:\" ; Home drive
$UserDirServer="CONGRESS-SVR1" ; Server holding the user directories
$Win32Admin = CreateObject("Win32Admin")
;Start Move
$UserDirList="G:\MoveDirs\Dirs.txt"
Open(1,$UserDirList,2)
$Dir=Readline(1)
While $Dir<>""
$SourceShare=$SourceServer + $Dir ; Share on source server to be removed
$DestShare=$DestServer + $Dir ; Share on destination server to be created
$SourceUserDir=$SourceDir + $Dir ; Path of the user dir on source server
$DestUserDir=$DestSharePath + $Dir ; Path of the user dir on destination server
$RmtUserDir=$MappedDrive + $Dir ; Location on the source server of the destination path
$Info = $Win32Admin.NetShareGetInfo ($UserDirServer, $Dir)
If $Info[+9] = 0
Shell "RmtShare $SourceShare /DELETE"
Shell "Robocopy $SourceUserDir $RmtUserDir /E /SEC /MOVE /XF paradox.cfg /LOG+:MoveUserDir.txt"
Shell "Robocopy $SourceUserDir $RmtUserDir paradox.cfg /SEC /LOG+:MoveUserDir.txt"
Shell "RmtShare $DestShare=$DestUserDir"
Shell "NTUser -s $PDC change $Dir -home_dir $DestServer$Dir -home_dir_drive $HomeDirDrive"
EndIf
$Dir=Readline(1)
Loop
Close(1)
Return
Thanks especially to Howard Bullock who added another funtion to his Win32Admin.dll which allowed me to do this.
Can I just ask though, have I used the function correctly or is there a better way of doing it?
Thanks
Ju