3

Need a PowerShell command to display drive letter and path it is mapped to.

In other words a command that shows me the same thing Windows Explorer would.

Tried this:

Get-WmiObject -Class Win32_MappedLogicalDisk | select Name, ProviderName

and it is missing several drives (listed in Windows Explorer).

  • Does Get-PSDrive show these missing drives? Is there something special or weird about these drives that are missing? Are they all mappings to a Windows server? – Zoredache Dec 29 '16 at 18:50
  • Do you specifically wish to exclude local filesystem drives? – Jeff Zeitlin Dec 29 '16 at 18:51
  • How about a good old NET USE command from Powershell or a command prompt? – Pimp Juice IT Dec 29 '16 at 18:55
  • 2
    What do you mean 'net use` doesn't work under powershell? It works perfectly fine. Perhaps you should spend some type in your question elaborating about why you need this, and how these particular drives were mapped in the first place. Additional context may help us figure out what the problem is and get you an answer. – Zoredache Dec 29 '16 at 19:16
  • 2
    Instead of mentioning what you see it would be far mor helpfull to actually show what you see. Post a screenshot of your explorer window and the output of Get-PSDrive. – Lieven Keersmaekers Dec 29 '16 at 19:21
2

TryNET USE command from Powershell

Ok. net use worked. I can swear I tried that before and it did not work. I think this is because I was trying to map a network drive last time I used net use. – Kolob Canyon

3

On the assumption that you do not wish to exclude drives that point to the local filesystem, I believe that

Get-PSDrive -PSProvider FileSystem | Select-Object name, @{n="Root"; e={if ($_.DisplayRoot -eq $null) {$_.Root} else {$_.DisplayRoot}}}

will serve your need. If you do wish to exclude drives that point to the local filesystem, you may find

Get-PSDrive -PSProvider FileSystem | Select-Object Name, DisplayRoot | Where-Object {$_.DisplayRoot -ne $null}

to be more to your liking.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.