Automation

 View Only
Expand all | Collapse all

Get vCenter of a harddisk

  • 1.  Get vCenter of a harddisk

    Posted Oct 27, 2014 07:12 PM

    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?



  • 2.  RE: Get vCenter of a harddisk
    Best Answer

    Posted Oct 27, 2014 07:47 PM

    Try like this

    Get-VM | Get-HardDisk |

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

        Name,

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



  • 3.  RE: Get vCenter of a harddisk

    Posted Oct 27, 2014 07:52 PM


    Ok great thanks again.