VMware Cloud Community
TheVMinator
Expert
Expert
Jump to solution

Get vCenter of a harddisk

I have a bunch of harddisk objects such as obtained by

get-vm | get-harddisk

Once I have the harddisk object in the pipeline, how can I go up and get the vcenter name as a great-great-great grandparent object?

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VM | Get-HardDisk |

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

    Name,

    @{N="vCenter";E={$_.Uid.Split('@')[1].Split(':')[0]}}


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VM | Get-HardDisk |

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

    Name,

    @{N="vCenter";E={$_.Uid.Split('@')[1].Split(':')[0]}}


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

0 Kudos
TheVMinator
Expert
Expert
Jump to solution


Ok great thanks again.

0 Kudos