<#
To create a mapped network drive in Powershell, you use:
New-PSDrive -Name “S” -Root “\\Server01\Scripts” -Persist -PSProvider “FileSystem”

Although this is meant for remote servers, I tried referring the local machine as a server and it worked.

New-PSDrive -Name “S” -Root “\\localhost\Scripts” -Persist -PSProvider “FileSystem”

The only drawback was there’s no entry in File Explorer (you shouldn’t be using that anyway). Additionally, a problem was found trying to remove this new drive:

Get-PSDrive -Name S | Remove-PSDrive -force
Nope, drive still shows in Get-PSDrive

Remove-PSDrive -Name S -PSProvider FileSystem -Force
Nope, still there.

Finally…

Net Use S: /del (old school command)
This worked!

Funny thing though. Retrying this exercise a second time created the drive as before but now Get-PSDrive S | Remove-PSDrive -force worked just fine.

Live and learn I guess…

tags: Mapped Drive, drive, drives, mapping drives, Remove-PSDrive, Get-PSDrive, Powershell
#>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s