Saturday, April 4, 2009

Power Shell

Been playing with Power Shell and here is a script for mapping drives. Simple Domain and DHCP makes this useless.

#first make sure to remove any previous mappings
net use "drive letter": /delete /Y

$ourip = (ipconfig | findstr .Gateway.*[0-9].\.).Split()[-1]

$city1 = "ip_of_gateway"
$city2 = "ip_of_gateway"
$city3 = "ip_of_gateway"

if ($ourip -match $var) {net use t: \\ip_address\share}
if ($ourip -match $var) {net use t: \\ip_address\share}
if ($ourip -match $var) {net use t: \\ip_address\share}
else {net use t: \\ip_address\share}

0 comments: