Reply to Message

View discussion in a popup

Replying to:
LucD
Leadership
Leadership

Try something like this

$diskModes = [VMware.Vim.VirtualDiskMode]::independent_nonpersistent,[VMware.Vim.VirtualDiskMode]::nonpersistent

foreach($vm in (Get-View -ViewType VirtualMachine -Property Name,Config.Hardware.Device -Filter @{'Config.Template'='False'})){

  $vm.Config.Hardware.Device |

  where{$_ -is [VMware.Vim.VirtualDisk] -and $diskModes -contains $_.Backing.DiskMode} |

  Select  @{N="VM";E={$vm.Name}},

    @{N="Disk";E={$_.DeviceInfo.Label}},

    @{N="Mode";E={$_.Backing.DiskMode}},

    @{N="CapacityGB";E={$_.capacityInKB/1MB}},

    @{N="Filename";E={$_.Backing.FileName}}

}

To get the syntax highlighted code, I currently use the PowerShell ISE addon from Windows PowerShell V3 ISE: Copy As HTML Add-On


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos