# encoding: ascii
# api: powershell
# title: map network drive
# description: Map network drive using powershell to call wscript.network. psdrive just does not act the same as a mapped network drive. I finally wrote these to connect to specific servers and directories to move files around.
# version: 0.1
# type: script
# author: 4wheels
# license: CC0
# x-poshcode-id: 4054
# x-archived: 2015-05-07T23:43:49
# x-published: 2015-03-27T22:52:00
#
#
# map2_gps_prod.ps1
# Maps a network drive using PowerShell
# 
# 
# 
#

	$Drive = "O:"
	$UNC = "\\ampwcsqlsvr2\nam401k"
cls

# if the drive exists just remove it
	
	if (((New-Object -Com WScript.Network).EnumNetworkDrives() | Where-Object `
{$_ -eq $Drive})) 
	{ # true remove drive
	
	# Create the Com object with New-Object -com
	$net = $(New-Object -comobject WScript.Network)
	$net.RemoveNetworkDrive($Drive,1)
	
	
	} 
# if the drive does not exist just add it
if (!((New-Object -Com WScript.Network).EnumNetworkDrives() | Where-Object `
{$_ -eq $Drive}))
		{
		# Create the Com object with New-Object -com
		$net = $(New-Object -comobject WScript.Network)
		$net.mapnetworkdrive($Drive,$Unc) 
		}

# Launches windows Explorer and goes to the maped drive
explorer.exe $Drive
