none
Correlate Hard Disk Number with OS Disk Letter RRS feed

  • Question

  • Hopefully this is the right forum for this question.

    As the title says, i am trying to correlate the HD number (Hard Disk 1) with a OS drive letter (C:). 

    I am trying to create a piece of automation where a user requests more space on a HD and the workflow goes and expands the disk. Sounds simple enough. And it is simple to get the VM > get-harddisk > set-harddisk. But if the user wants the D: expanded I need to be sure that (D: -eq "Hard disk 2"). The user doesn't know what the hard disk number is, they only know the letter.

    I have tried getting the $VMHD.CapacityKB and then getting the OS disk size and correlating them. If its a match than expand the disk. 

    Something like...

    $VMHD = Get-HardDisk -VM Server$VMHD.CapacityKB

    $drives = Get-WmiObject Win32_DiskDrive -Computername Server  

    if($Drive.size -eq $VMHD.CapacityKB){

        "yessssss....."

    }

    However, logical and physical size is not the same so that doesn't work. 

    Has anyone tried to do this before and if so, how?


    - Slow is smooth and smooth is fast.


    • Edited by Pete Barbuto Wednesday, April 15, 2015 8:29 PM I like editing stuff
    Wednesday, April 15, 2015 8:27 PM