1

I'm trying to create a D: drive in Windows, which points to some local directory (e.g. C:\DDrive) using PowerShell.

This code runs fine:

New-PSDrive -Name D -Root "C:\D_Drive\" -PSProvider "FileSystem"

But in the Windows Explorer no D:-drive is visible.

How does one use that command correctly? Also: the drive should be permanent, so I tried adding a "-Persist" parameter. But that leads to an error ("unknown parameter "-Persist"...").

2
  • Apparently only mapped UNC drives are supported, which is probably for the best since these can be persisted in "HKCU\Network" with the -persist option and can be reflected to both logon sessions in a linked UAC logon (standard and elevated). For the C: drive, you can use the C$ administrative share, e.g. "\\localhost\C$\D_Drive". Commented May 23, 2019 at 11:50
  • BTW, whoever developed PSDrive on the PowerShell team is kind of clueless. The colon has always been part of the drive/device name, just as it's optional for other DOS devices such as "CON", aka "CON:". The name of the NT device mountpoint (i.e. SymbolicLink object) includes the colon, and we need it when opening a volume directly such as "\\.\C:". Commented May 23, 2019 at 11:52

2 Answers 2

1

Just run:

subst D: "C:\D_Drive\"

in non-elevated PS session (don't run as Administrator).

Sign up to request clarification or add additional context in comments.

2 Comments

subst.exe drives (i.e. drive-letter devices created via DefineDosDevice that target a filesystem directory) are not without issues. First, as you mention, they're not reflected to a linked logon session. They also cause some APIs to fail (e.g. GetVolumePathName) that assume that a drive-letter is either a junction to a volume device or a mapped network drive, but not a junction to a filesystem directory.
That's actually a good piece of information, thank you. Now I need to test some stuff with it to see for myself. Here we go again... :)
0

The New-PSDrive command only creates a mapping that is visible in PowerShell. It's not shown in explorer at all.

Here are two other questions that ask the same thing:

https://community.spiceworks.com/topic/649234-powershell-mapped-drive-not-showing-in-my-computer

https://social.technet.microsoft.com/Forums/windowsserver/en-US/96222ba2-90f9-431d-b05a-82b804cdc76e/newpsdrive-does-not-appear-in-explorer?forum=winserverpowershell

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.