PoshCode Archive  Artifact [c5f8890522]

Artifact c5f8890522af9696683465609912e9d77a82b2870915cce1f172271154f73f37:

  • File Add-virtual-hd-type.ps1 — part of check-in [fa63524da9] at 2018-06-10 13:04:50 on branch trunk — Add a type property to the VirtualHarddisk object to associate a disks type…. too big to past into twitter :D (user: unknown size: 860)

# 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
                    }
            ) 
    }
}