Need a PowerCLI script to get the "ESXi host name", "Host Hardware Vendor Name", "Host hardware model", "IP address", "Product full name"
We have about 15 vCenters which I want to grab all the vCenter hosts information with one time. Thanks in advance.
In that case, just add the name
$global:DefaultVIServers | ForEach-Object {
$vc = $_
Get-VMHost -Server $vc |
Select @{N='vCenter';E={$vc.Name}},Name,
@{N='Vendor';E={$_.ExtensionData.Hardware.SystemInfo.Vendor}},
@{N='Model';E={$_.ExtensionData.Hardware.SystemInfo.Model}},
@{N='IP';E={(Get-VMHostNetworkAdapter -VMHost $_ -VMKernel -Name vmk0).IP}},
@{N='Product';E={$_.ExtensionData.Config.Product.FullName}}
} | Export-Csv C:\Temp\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try like this
Get-VMHost -Server $vc |
Select @{N='vCenter';E={$vc.Name}},Name,
@{N='Vendor';E={$_.ExtensionData.Hardware.SystemInfo.Vendor}},
@{N='Model';E={$_.ExtensionData.Hardware.SystemInfo.Model}},
@{N='IP';E={(Get-VMHostNetworkAdapter -VMHost $_ -VMKernel).IP -join '|'}},
@{N='Product';E={$_.extensionData.Client.ServiceContent.About.FullName}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
output I'm seeing vCenter production information, I need ESX hypervisor version, can you please correct it and also, please add below requirements -
how this can turned into a tabular format with .csv output - tabular format should be -->
HOST HOST_VENDOR HOST_MODEL IP_ADDRESS PRODUCT_FULLNAME (ESXi)
thank you
Try like this
Get-VMHost -Server $vc |
Select @{N='vCenter';E={$vc.Name}},Name,
@{N='Vendor';E={$_.ExtensionData.Hardware.SystemInfo.Vendor}},
@{N='Model';E={$_.ExtensionData.Hardware.SystemInfo.Model}},
@{N='IP';E={(Get-VMHostNetworkAdapter -VMHost $_ -VMKernel).IP -join '|'}},
@{N='Product';E={$_.ExtensionData.Config.Product.FullName}}
} | Export-Csv C:\Temp\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
for some reason, it is not capturing the vCenter information in the first tab. Could you please have a look.
and also, in the IP address tab, capturing 2 different IPs. I need only the IP address which is assigned to the host, not any thing else.
Previously, I used to receive emails when some one respond to my query. But, these days, I'm not receiving, not sure what is the reason....?
It seems I lost 1 line when I copied the snippet.
This should fix the vCenter issue.
On the IP addresses, those are the IP addresses assigned to the VMKernle adapters, if a node has more than 1 you will see more than one.
In such a case which IP address do you want to see? The one for vmk0?
There is an issue with emails being sent out for threads since more than 1 week.
Not sure how far the website admins are with fixing that.
$vc = $_
Get-VMHost -Server $vc |
Select @{N='vCenter';E={$vc.Name}},Name,
@{N='Vendor';E={$_.ExtensionData.Hardware.SystemInfo.Vendor}},
@{N='Model';E={$_.ExtensionData.Hardware.SystemInfo.Model}},
@{N='IP';E={(Get-VMHostNetworkAdapter -VMHost $_ -VMKernel).IP -join '|'}},
@{N='Product';E={$_.ExtensionData.Config.Product.FullName}}
} | Export-Csv C:\Temp\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thanks, it is capturing the vCenter info now. And yes, only the vmk0 is needed (management network IP address).
In that case, just add the name
$global:DefaultVIServers | ForEach-Object {
$vc = $_
Get-VMHost -Server $vc |
Select @{N='vCenter';E={$vc.Name}},Name,
@{N='Vendor';E={$_.ExtensionData.Hardware.SystemInfo.Vendor}},
@{N='Model';E={$_.ExtensionData.Hardware.SystemInfo.Model}},
@{N='IP';E={(Get-VMHostNetworkAdapter -VMHost $_ -VMKernel -Name vmk0).IP}},
@{N='Product';E={$_.ExtensionData.Config.Product.FullName}}
} | Export-Csv C:\Temp\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
hello,
with this script, can you help to get the Cluster name as well. My requirement is, if I filter the vCenter name, should show the Cluster name along with what are the hosts which are there with that cluster.
TIA
Try like this
$global:DefaultVIServers | ForEach-Object {
$vc = $_
Get-VMHost -Server $vc |
select @{N='vCenter';E={$vc.Name}},Name,
@{N='Cluster';E={(Get-Cluster -VMHost $_).Name}},
@{N='Vendor';E={$_.ExtensionData.Hardware.SystemInfo.Vendor}},
@{N='Model';E={$_.ExtensionData.Hardware.SystemInfo.Model}},
@{N='IP';E={(Get-VMHostNetworkAdapter -VMHost $_ -VMKernel -Name vmk0).IP}},
@{N='Product';E={$_.ExtensionData.Config.Product.FullName}}
} | Export-Csv C:\Temp\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Can we collect the same information at Cluster level and export to CSV ? I mean for each cluster in vSphere ?
thanks
vmk
That last script includes the cluster, or do you mean something else?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you LucD. I'm all set, that is what i was looking exactly. Let me try now
thanks
vmk
LucD,
I tested it. Worked for me.
Thank you.
vmk
Thank you its work fine and can we add up time in it?
You can add a calculated property
@{N='Uptime';E={
"$([math]::round($_.ExtensionData.Summary.QuickStats.Uptime / 86400, 0)) days"
}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you for sharing this! Very helpful.
I'd like to include a few other items and I haven't been able to figure out what I need.
Storage I/O control
DQLEN
NTP servers
DNS servers
Thanks again