Reply to Message

View discussion in a popup

Replying to:
RvdNieuwendijk
Leadership
Leadership

You are right. The output of Get-Harddisk does not have a VM property. In this case, you can use the Parent property that contains the VM. For example,

Get-VM | Get-HardDisk | Select Parent,CapacityGB

A more general solution is to use the -PipelineVariable parameter with the Get-VM cmdlet to save the current VM in a variable. Then you can use a calculated property to display the VM name, as follows:

Get-VM -PipelineVariable VM | Get-HardDisk | Select @{Name='VM';Expression={$VM.Name}},CapacityGB

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition