14

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).

Kellen Stuart
  • 618
  • 3
  • 10
  • 20

3 Answers3

17

In PowerShell 5 (Windows 10) and above, use:

Get-SMBMapping

https://docs.microsoft.com/en-us/powershell/module/smbshare/get-smbmapping?view=win10-ps

Minkus
  • 432
5

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.

Jeff Zeitlin
  • 5,136
4

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. – Kellen Stuart