We had a problem where the server group was pushing out incorrect drive mappings which caused multiple connections (with different drive letters) to the same server. The problem was fixed with the Batch file containing the following:
for /f "tokens=2,3" %%a in ('net use') do if .%%b==.\\Ncprolawapp01\ProLaw net use %%a /Delete
for /f "tokens=2,3" %%a in ('net use') do if .%%b==.\\Ncatsqlapp01\ProLaw net use %%a /Delete
net use R: \\NCPROLAWAPP01\PROLAW
What I’m looking to do now is put this into a Powershell script so that it runs on first time user setup on future images. I haven’t had time to lookup much but I know the above lines will not function in Powershell. Just looking for some advice.
you can check using wmi if there is already a drive mapped to your server like this :
You can disconnect the drive using the old ‘net use /d’