PowerCLI

 View Only
  • 1.  get-vm with datacenter location column

    Posted Jan 06, 2015 08:02 PM

    how do I get VM info with datacenter location included in a column?

    I check $_Extensiondata.config and did not se it under there



  • 2.  RE: get-vm with datacenter location column

    Posted Jan 06, 2015 08:55 PM

    This isn't the most elegant, but add it as a property with something like this:

    $VMs = @()

    Foreach ($cluster in (Get-Cluster)) {

       Foreach ($vm in (Get-VM)) {

          $vm | Add-Member -membertype NoteProperty -name Cluster -value $cluster.Name

          $VMs += $vm

          }

    }

    $VMs | Sort Cluster | Select-Object Cluster, Name



  • 3.  RE: get-vm with datacenter location column
    Best Answer

    Posted Jan 06, 2015 09:49 PM

    Try this:

    Get-VM $vm | Format-table Name,

    @{Name="Datacenter";Expression={$_.vmhost.parent.parentfolder.parent};a="center"} -a

    Tested with a VM in a "clustered" host. I think it may change if host is not in a Cluster.

    Hope it works



  • 4.  RE: get-vm with datacenter location column

    Posted Jan 07, 2015 06:06 AM

    thank you for locating that object