Discussion:
script for moving to DFS
(too old to reply)
Mike Brierley
2004-04-29 16:15:51 UTC
Permalink
We are moving a few of our file servers behind DFS and would like to
remap the drives on our systems with a script.

something like:

enumerate drives into an array.
Parse each array object mapped drive for \\fileserver1\share
if exist
remove mapping and remap with \\domain\dfsroot\share


I know I cant be the first one to run across this.


Mike
Mike Brierley
2004-05-03 18:26:13 UTC
Permalink
Post by Mike Brierley
We are moving a few of our file servers behind DFS and would like to
remap the drives on our systems with a script.
enumerate drives into an array.
Parse each array object mapped drive for \\fileserver1\share
if exist
remove mapping and remap with \\domain\dfsroot\share
I know I cant be the first one to run across this.
Mike
I found this as a solution:

Taken from Stein Borge's "Managing Enterprise Systems with the Windows
Script Host" Apress - ISBN 1-893115-67-4

'migrate.vbs
Dim objWshNetwork, nF
Dim sShare, sDrive, objEnumNetwork

Set objWshNetwork = CreateObject("WScript.Network")

Set objEnumNetwork = objWshNetwork.EnumNetworkDrives

For nF = 0 To objEnumNetwork.Count - 1 Step 2

'get the drive letter and share name for the current share
sShare = objEnumNetwork(nF)
sDrive = objEnumNetwork(nF + 1)

'check if the current share is connected to s-fileserv1
If StrComp(Left(sShare, 12), "\\fileserv1\", vbTextCompare) = 0 Then
'remove the existing share
objWshNetwork.RemoveNetworkDrive sDrive, True, True

'remap the drive to the new server
objWshNetwork.MapNetworkDrive sDrive, _ "\\domain\dfsroot\" &
Mid(sShare,13), True

End If

Next

Loading...