PoshTip #35 – How To List Your Windows Mapped Drives?

We can query network drives using PowerShell with the Get-WmiObject cmdlet. You can query the Win32_MappedLogicalDisk WMI class which represents network storage devices that are mapped as logical disks on the computer system.

Below is an example:

PS > $computer = "localhost"
PS > Get-WmiObject Win32_MappedLogicalDisk -ComputerName $computer

Name ProviderName
---- ------------
P:   \\nas1\Private
Z:   \\nas2\Public

Note: You can query a remote computer with the $computer variable.

Many properties are available. Just use the Format-List cmdlet to list all the properties:

PS > Get-WmiObject Win32_MappedLogicalDisk -ComputerName $computer | fl *

Now you can easily display some interesting properties:

PS > Get-WmiObject Win32_MappedLogicalDisk -computerName $computer | select Name, ProviderName,FileSystem,@{Name="Total Size";Expression={
$_.size / 1GB}}, @{Name="Free Space";Expression={$_.freespace / 1GB}} | ft -AutoSize

Name ProviderName        FileSystem       Total Size       Free Space
---- ------------        ----------       ----------       ----------
P:   \\nas1\Private      NTFS             3681.69588470459 579.900218963623
Z:   \\nas2\Public       NTFS             3681.69588470459 579.900218963623

 

Thanks for reading! You can follow me on Twitter @PrigentNico

About Nicolas 274 Articles
I work as an IT Production Manager, based in Paris (France) with a primary focus on Microsoft technologies. I have 10 years experience in administering Windows Servers. . I am a Microsoft MVP for Cloud & Datacenter Management. I also received the PowerShell Hero 2016 award by PowerShell.0rg. And finally, I am "MCSE: Cloud Platform and Infrastructure", "MCSA: Windows Servers", "Administering & Deploying SCCM", and CheckPoint CCSA certified.