BaltoStar
BaltoStar

Reputation: 8967

How do I map drive letter to a local path in PowerShell?

In PowerShell, is it possible to map a drive letter to a local path ?

So for example map x:\ to c:\myfolder1\myfolder2\

Upvotes: 7

Views: 7524

Answers (2)

Henrique
Henrique

Reputation: 41

The following statement will also work (and it only uses native powershell cmdlets):

New-PsDrive -Name [DRIVELETTER] -PSProvider filesystem -Root "\\localhost\C$\[PATH]" -Persist

Upvotes: 4

Kev
Kev

Reputation: 119806

You could use subst:

subst x: c:\myfolder1\myfolder2\

or New-PSDrive:

New-PSDrive -Name x -PSProvider FileSystem -Root c:\myfolder1\myfolder2\

Upvotes: 9

Related Questions