**** Cross posted from DFS ****

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

Re: scripting mapped shares by Marty

Marty
Thu Apr 29 12:15:23 CDT 2004


"Mike Brierley" <mbrierley@co.marin.ca.us> wrote in message
news:%23LD5aWgLEHA.2396@TK2MSFTNGP12.phx.gbl...
> **** Cross posted from DFS ****
>
> 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
>


This might help you with the enumeration part:

Dim objNetwork
Dim colDrives
Dim i

Set objNetwork = WScript.CreateObject("WScript.Network")
Set colDrives = objNetwork.EnumNetworkDrives
For i = 0 To colDrives.Count - 1 Step 2
WScript.Echo vbNewLine & colDrives(i) & vbTab & colDrives(i + 1)
Next




Re: scripting mapped shares by Mike

Mike
Thu Apr 29 14:02:25 CDT 2004

Marty List wrote:

> "Mike Brierley" <mbrierley@co.marin.ca.us> wrote in message
> news:%23LD5aWgLEHA.2396@TK2MSFTNGP12.phx.gbl...
>
>>**** Cross posted from DFS ****
>>
>>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
>>
>
>
>
> This might help you with the enumeration part:
>
> Dim objNetwork
> Dim colDrives
> Dim i
>
> Set objNetwork = WScript.CreateObject("WScript.Network")
> Set colDrives = objNetwork.EnumNetworkDrives
> For i = 0 To colDrives.Count - 1 Step 2
> WScript.Echo vbNewLine & colDrives(i) & vbTab & colDrives(i + 1)
> Next
>
>
>
Thanks for the start....

Now to finger out some of the other aspects.


M.


Re: scripting mapped shares by tomthumbkop

tomthumbkop
Thu Apr 29 16:26:43 CDT 2004


Add in:
objNetwork.RemoveNetworkDrive colDrives(i), True, True
objNetwork.MapNetworkDrive colDrives(i), strPath, True

Where strPath is the new UNC path and it should remove the old mappin
and create the new on.

Marty List wrote:
> *"Mike Brierley" <mbrierley@co.marin.ca.us> wrote in message
> news:%23LD5aWgLEHA.2396@TK2MSFTNGP12.phx.gbl...
> > **** Cross posted from DFS ****
> >
> > We are moving a few of our file servers behind DFS and would lik
> 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
> >
>
>
> This might help you with the enumeration part:
>
> Dim objNetwork
> Dim colDrives
> Dim i
>
> Set objNetwork = WScript.CreateObject("WScript.Network")
> Set colDrives = objNetwork.EnumNetworkDrives
> For i = 0 To colDrives.Count - 1 Step 2
> WScript.Echo vbNewLine & colDrives(i) & vbTab & colDrives(i + 1)
> Next


-
tomthumbko
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
-----------------------------------------------------------------------


Re: scripting mapped shares by Mike

Mike
Fri Apr 30 13:26:05 CDT 2004

tomthumbkop wrote:
> Add in:
> objNetwork.RemoveNetworkDrive colDrives(i), True, True
> objNetwork.MapNetworkDrive colDrives(i), strPath, True
>
> Where strPath is the new UNC path and it should remove the old mapping
> and create the new on.
>
> Marty List wrote:
>
>>*"Mike Brierley" <mbrierley@co.marin.ca.us> wrote in message
>>news:%23LD5aWgLEHA.2396@TK2MSFTNGP12.phx.gbl...
>>
>>>**** Cross posted from DFS ****
>>>
>>>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
>>>
>>
>>
>>This might help you with the enumeration part:
>>
>>Dim objNetwork
>>Dim colDrives
>>Dim i
>>
>>Set objNetwork = WScript.CreateObject("WScript.Network")
>>Set colDrives = objNetwork.EnumNetworkDrives
>>For i = 0 To colDrives.Count - 1 Step 2
>>WScript.Echo vbNewLine & colDrives(i) & vbTab & colDrives(i + 1)
>>Next *
>
>
>
>
> --
> tomthumbkop
> ------------------------------------------------------------------------
> Posted via http://www.codecomments.com
> ------------------------------------------------------------------------
>
thanks for the reply, I still dont have anything working. I'll keep
looking.


Re: scripting mapped shares by Marty

Marty
Fri Apr 30 21:26:10 CDT 2004


"Mike Brierley" <mbrierley@co.marin.ca.us> wrote in message
news:OJ36bCuLEHA.3664@TK2MSFTNGP10.phx.gbl...
>
> thanks for the reply, I still dont have anything working. I'll keep
> looking.
>

If you post what you have so far I will add to it / make recommendations.




Re: scripting mapped shares by Mike

Mike
Mon May 03 13:30:57 CDT 2004

Marty List wrote:

> "Mike Brierley" <mbrierley@co.marin.ca.us> wrote in message
> news:OJ36bCuLEHA.3664@TK2MSFTNGP10.phx.gbl...
>
>>thanks for the reply, I still dont have anything working. I'll keep
>>looking.
>>
>
>
> If you post what you have so far I will add to it / make recommendations.
>
>
>
'migrate.vbs
'Created by Mike Brierley
'Version 0.7 First Beta
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, "\\xxxxxxxxxxx\fs1\" &
Mid(sShare,13), True

End If

Next