For various reasons I have inherited a mixed VSphere 4 and vSphere 5.1 estate with PowerCli 5.1 Release 2
As part of our daily checks, due to the departure of our VM Admin, I have been asked to create a report that shows all ESXi hosts from all 4 vcenter servers (2 are dedicated to the vSphere 4 environment, 2 are dedicated to the separate vSphere 5 environment) with the following output:
ESXi hostname, AnnotationEntity, ConnectionState, PowerState, DVS Status
So far, after connection to all 4 vCenter Servers, I can get ESXi hostname & Annotation via
Get-VMHost | Get-Annotation | Select, AnnotatedEntity, Value
and I can get ConnectionState and PowerState via
Get-VMHost | Select Name,ConnectionState,PowerState
but I am lost as to
a) How to get DVS Status (as seen when selecting the Distributed Switch and clicking the hosts tab) and
b) How to get this all, if possible, in one output either as output to screen or to a tabbed / csv file in the format
ESXi hostname, AnnotationEntity, ConnectionState, PowerState, DVS Status (order is not important as long as ESXi Hostname is the first column).
I'm sure this is a (relatively) simple script but would appreciate any advice as I have to get up to speed reasonably quickly so hoping someone out there is able to help / advise.
Many thanks,
Chris
That is some old stuff :smileygrin:
Can you check if the Get-VDSwitch returns the VDS? Especially in vSphere 4. For vSphere 5 it should work.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD
Yes - Get-VDSwitch does work on vSphere 4 - it returns the name of the switch, the number of ports, the mtu size, the version of vSphere and the vendor. Does that mean it might be possible to get the DVS Status?
What do you mean with status?
The health status?
I think that was introduced in vSphere 5.1
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try like this
$vds.ExtensionData.Runtime.HostMemberRuntime |
select @{N='VDS';E={$vds.Name}},
@{N='VMHost';E={Get-View -Id $_.Host -property Name | select -ExpandProperty Name}},
@{N='VDS Status';E={$_.Status}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks but sadly no - the code just sits at the >> prompt as if it was asking for more data to be entered.
On my personal ESXi 6.5 / PowerCli 6.5 system your code works fine - just not in my work ESXi 4.0U4 / PowerCli 5.1 Release 2 environment.
Chris
I guess v4.* is not supported, and I don't have a version to test against I'm afraid.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference