How to find DiskIndex of a Volume or Mount point using Powershell

This topic contains 4 replies, has 4 voices, and was last updated by Profile photo of subash es subash es 10 months, 1 week ago.

  • Author
    Posts
  • #34570
    Profile photo of Sub
    Sub
    Participant

    I am using Win32_Volume wmi class to report the Mount points and drive letters and labels etc..

    Get-WmiObject Win32_Volume | FT Caption,Label,FreeSpace,Capacity

    How to add DiskIndex to my report?

    I get DiskIndex using Win32_DiskPartition, but not able to map it with the result from my first command(Get-WmiObject Win32_Volume).

    Get-WmiObject Win32_DiskPartition | FT DiskIndex

    PS : I cannot use Win32_LogicalDisk class as it will not report the mount points..

  • #34573
    Profile photo of Brian B
    Brian B
    Participant

    Just to make sure I understand what you're trying to do. You want to get the physical disk number that a mount point is on, hence trying to match something from Win32_DiskPartition to something in Win32_Volume... so you can return the DiskIndex value from Win32_DiskPartition and make that part of your report along with the drive letter, path, etc...

    Correct? If so, i'm trying to find something that could be used between the two classes that would be able to match to ensure you're getting correct data. But nothing is jumping out at me.

    Brian

  • #34574
    Profile photo of Brian B
    Brian B
    Participant

    Actually, It doesn't appear there is any WMI methods of matching physical disk to mount point. Someone wrote something to do it, but it's not using WMI to get the disk index. They wrote their own class and it requires powershell remoting in order to get the data.

    http://www.powershelladmin.com/wiki/PowerShell_Get-MountPointData_Cmdlet

    Brian

  • #34575
    Profile photo of Jason Colotario
    Jason Colotario
    Participant

    I know you can run "diskpart" in POSH and then execute the "list disk" command which will output the index numbers of all volumes on the host. You should be able to do the same with PS remoting.

  • #34582
    Profile photo of subash es
    subash es
    Participant

    Thanks I will try Get-MountPointData Cmdlet and see if it works for me..

    I think diskpart doesn't show the drive letters or the mount points information. It only shows the disk index.

You must be logged in to reply to this topic.