Check and Map network drives by script to new name

Hello Experts,

We are doing a file server migration to DFS approximately 70 shares in 10 phases. (7 per phase)

Currently we don't use login scripts to map drives. However I know users have manual drive mappings.

I would like a script to check users drive mappings and then change to new name and keep same drive letter in a phased approach.

current mapping - fs-01admin
new mapping - contoso.co.ukns1admin



Do you mean something like this?
Note: This example doesn't do the actual mapping. It just ECHOs the command. Remove the ECHO to run it for real.



Do you mean something like this?
Note: This example doesn't do the actual mapping. It just ECHOs the command. Remove the ECHO to run it for real.



This seems to be on the right track however I don't know their drive letters they will be different for each user, I just want to keep their existing?



@echo off
setlocal
set OldShr=\fs-01admin
set NewShr=\contoso.co.ukns1admin
for /f "tokens=2-3" %%a in ('net use') do (
if /i "%OldShr%" equ "%%b" ECHO net use %%a %NewShr%
)

1:2:3:4:5:6:7:


Select all

Open in new window
jqBind('#answerOrCommentView .buttonsInline20-40711271-1','click',function(e){selectElementById('answerOrCommentViewInlineCode20-40711271-1');return false;});



@echo off
setlocal
set OldShr= "\fs-01Admin"
set NewShr= "\contoso.co.ukns1Admin"
for /f "tokens=2-3" %%a in ('net use') do (
if /i "%OldShr%" equ "%%b" net use %%a %NewShr%
)


Line 1
Character 1
Invalid character
800A0408
I get VBS compilation error



The code should be saved in a .bat file such as Remap.bat
Are you running this .bat in a CMD window?

It was tagged as "Windows Batch Scripting" so I thought a .bat file would be ok for you. Also, you responded to my first post.

Share this

Related Posts

There was an error in this gadget