VMware Cloud Community
vespavbb
Enthusiast
Enthusiast
Jump to solution

get Viserver from VM $_.

Hi,

is it possible to get the information of a VM on which VCenter the VM´s belongs?

I´m asking, because we have more vcenters....

connection to more vcenters example

$vmlist =  get-vm  | sort name

$myCol = @()

foreach ($vm1 in $vmlist)

{

   $vminfo =  $vm1 | Select name, Powerstate, NumCPU, MemoryGB,

    @{N="OS";E={$_.extensiondata.config.GuestFullName}},

    @{N="Cluster";E={$_.vmhost.parent}},

    @{N='vCenter';E={$_.get-viserverorsomethinglikethisName}}    # how can i get the vcenter back from the vm object?

    $myCol += $VMInfo

}

$mycol

VCP4,VCP5,VCP6,VCP7,VCP8
Tags (1)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

@{N = 'vCenter'; E = { ([uri]$_.ExtensionData.Client.ServiceUrl).Host } },


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

@{N = 'vCenter'; E = { ([uri]$_.ExtensionData.Client.ServiceUrl).Host } },


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

0 Kudos
vespavbb
Enthusiast
Enthusiast
Jump to solution

perfect!

thanks Luc

VCP4,VCP5,VCP6,VCP7,VCP8
0 Kudos