To save time and efforts, you can use Get-View to retrieve PowerCLI views from previously retrieved view objects.

Prerequisites

Verify that you are connected to a vCenter Server system.

Procedure

  1. Get a view of the VM2 virtual machine by name.
    $vm2 = Get-View -ViewType VirtualMachine -Filter @{"Name" = "VM2"}
  2. Populate the $vmhostView object.
    $vmhostView = Get-View -Id $vm2.Runtime.Host
  3. Retrieve the runtime information for the $vmhostView object.
    $vmhostView.Summary.Runtime