# encoding: ascii
# api: powershell
# title: Add virtual hd type
# description: Add a type property to the VirtualHarddisk object to associate a disks type…. too big to past into twitter :D
# version: 4.1
# license: CC0
# x-poshcode-id: 2087
# x-archived: 2010-08-22T00:44:59
#
#
#requires -PsSnapIn VMware.VimAutomation.Core -version 4.1
Foreach ($VM in Get-VM)
{
    Foreach ($HD in Get-HardDisk -VM $VM)
    {
        Add-Member -InputObject $HD `
            -Name 'Type' `
            -MemberType 'noteproperty' `
            -passthru `
            -Value $( `
                $VM.ExtensionData.Config.Hardware.device |
                    Where-Object {$_.key -eq $HD.ExtensionData.ControllerKey} |
                    ForEach-Object {
                        $_.gettype().name
                    }
            ) 
    }
}
