lit
lit

Reputation: 16236

How to get network drive root location?

I need to get the root location of a network mapped drive. Using Get-Location looks promising.

PS W:\> (Get-Location).Drive

Name           Used (GB)     Free (GB) Provider      Root
----           ---------     --------- --------      ---- 
W                 384.97        546.54 FileSystem    \\RT-AC66U\files

However, when I reference the Root member, it gives back the Name value.

PS W:\> (Get-Location).Drive.Root
W:\

How can I get the Root value?

Upvotes: 1

Views: 387

Answers (1)

cet51
cet51

Reputation: 1226

A better way of viewing this information, in my opinion, is to run the following in a normal powershell console.. if ran in an elevated console it will return nothing.

Get-WmiObject -Class Win32_MappedLogicalDisk | select Name, ProviderName

That will show all of your mapped drives, including their letters and network locations.

Upvotes: 1

Related Questions