Hi,
Basically I am trying to disconnect shares from old DC1 server and map shares on a new DC2 server (having the same permissions and same share names)
BAT script runs a PS script (to disconnect drives) and then executes map commands.
BAT script
@echo off
#runs a PS script
PowerShell.exe -ExecutionPolicy Bypass -Command "& '%~dpn0.ps1'"
#maps drives
net use * \\dc2\production /P:Yes
net use * \\dc2\finance /P:Yes
PS script
#Delete drives
Import-Module activedirectory
$mapped = Get-WmiObject Win32_MappedLogicalDisk | Select DeviceId, ProviderName
foreach ($item in $mapped) {
if ($item.ProviderName -eq '\\DC1\production') {net use $item.DeviceId /del}
}
$mapped = Get-WmiObject Win32_MappedLogicalDisk | Select DeviceId, ProviderName
foreach ($item in $mapped) {
if ($item.ProviderName -eq '\\DC1\finance') {net use $item.DeviceId /del}
}
Everything...
↧
Mapping script for shares
↧