2

In DISKPART.EXE, I get the info when multiple mount points are assigned to a volume. In the picture we see that Drive G: can also be accessed using D:\SQL\MSSQL13.MSSQLSERVER\DATA\ or D:\BlaBla:

DISKPART result

But I can't find the same info using PowerShell's Get-Volume or Get-WMIObject -Class Win32_Volume. Does anyone knows how to extract this info using a native PowerShell function?

Get-Volume result

I thought of extracting the info by calling DISKPART.EXE inside PowerShell but I would prefer an native PowerShell function like Get-Volume.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
PollusB
  • 1,726
  • 2
  • 22
  • 31

1 Answers1

1

Perhaps surprisingly, you can look up mount points via the Win32_MountPoint class:

Get-WmiObject Win32_MountPoint | Select-Object Directory, Volume

Further details can be obtained by looking up the references:

Get-WmiObject Win32_MountPoint | ForEach-Object {
    $dir = [wmi]$_.Directory | Select-Object -Expand Name
    $vol = [wmi]$_.Volume
    New-Object -Type PSObject -Property @{
        Directory   = $dir
        Label       = $vol.Label
        DriveLetter = $vol.DriveLetter
        FileSystem  = $vol.FileSystem
        DeviceId    = $vol.DeviceId
    }
}
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328