Is there any powercli command or script available from which i can pull vcenter version and esxi host belogs to which vcenter server?
Not sure if are looking for the ESXi version or the vCenter version.
Get-VMHost |
Select Name,Version,@{N="vCenter";E={$_.ExtensionData.CLient.ServiceUrl.Split('/')[2]}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Many Thanks LucD,
Perfect, I tried it and able to pull vcenter name that esxi host belongs to.
I need to pull vCenter version, not esxi server version.
Regards,
Kunal udapi
Try something like this
foreach($esx in Get-VMHost){
$esx | Select Name,
@{N="vCenter";E={$_.ExtensionData.CLient.ServiceUrl.Split('/')[2]}},
@{N="vCenter version";E={
$global:DefaultVIServers |
where {$_.Name -eq ($esx.ExtensionData.CLient.ServiceUrl.Split('/')[2])} |
%{"$($_.Version) build $($_.Build)"}
}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
It will be more helpful if you can please clarify this 'split line'
[vSphere PowerCLI] C:\> $h.ExtensionData.Client.ServiceUrl
So while spliting, $h.ExtensionData.Client.ServiceUrl.split('/')[2], how VC name becomes 3 rd value in the array.
1st value is https and 2nd value shows "blank"
Sure, the URL looks something like this "http://server/whatever"
By splitting on the '/' character, you will get an array of values:
1 - "http"
2 - empty string (there is nothing between the 2 slashes
3 - "server"
4 - ...
We want the servername, and since a PowerShell arrays start indexing from 0, we need to use the index 2 to get it.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You can get the VC version with $global:DefaultVIServer.ExtensionData.Content.About after you connect to VC
I liked this. I changed it a little so you can capture the output to a $variable and added the ESXi's version and build too.
$myESXiHosts = Get-VMHost | %{ $_ | Select Name,
@{N="ESXi Version";E={"$($_.Version) build $($_.Build)"}},
@{N="vCenter";E={$_.ExtensionData.CLient.ServiceUrl.Split('/')[2]}},
@{N="vCenter version";E={
$global:DefaultVIServers |
where {$_.Name -eq ($_.ExtensionData.CLient.ServiceUrl.Split('/')[2])} |
%{"$($_.Version) build $($_.Build)"}
}}
}
PowerCLI/Get-ESXi-Hosts-and-vCenter-Builds.ps1 at master · cajeeper/PowerCLI · GitHub
Hi
Is there a way to get the output of the vcenter name as well with
$global:Defausltviservers.extensiondata.content.about | ft -auto
ok I think I got it.