Hi,
I need a powershell script to collect the below given ESX host information from the Virtual Center. My environment VC:2.5, ESX hosts: 2.5, 3, 3.5
At present i have individual powershell one liner scripts for getting these details. Would be more useful to have a single script. Tried VESI, but not getting the report in the below given format.
ESX host name | Version | Build Number | Manufacturer | Model | Processor Type | Physical CPU count | Cores Count | Service Console IP | vMotion IP | HBA count | Physical NICS count
Thanks in advance!
Then I'm at my wits end here.
It works for me and Robert also confirmed it worked for him.
Although I can't see why this would solve the problem, you could ultimately try an upgrade to PowerShell v2 RTM.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try this
Get-VMHost | Select Name, Version, Build, Manufacturer, Model, ProcessorType, NumCPU, @{N="Cores";E={($_| Get-View).Hardware.CpuInfo.NumCpuCores}}, @{N="Service Console IP";E={(($_|Get-VMHostNetwork).ConsoleNic | Select IP).IP}}, @{N="vMotion IP";E={(($_|Get-VMHostNetwork).VirtualNic | Select IP).IP}}, @{N="HBA count";E={($_| Get-VMHostHba | where {$_.Type -eq "FibreChannel"}).Count}}, @{N="Physical NICS count";E={($_ | Get-View).Config.Network.Pnic.Count}}
For the Cores field I wasn't sure if you want the number of cores per processor block or the total number of cores on the server.
It now shows the cores per processor block.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
You can also try below code snippet.
Connect-VIServer <server> -User <user> -Password <password> $HostReport = @() Get-VMHost |Get-View |%{ $Report = "" | select Hostname, version, Build, manufacture, Model,cpu_model, core_num, ip_address,vmotion_ip, HBA_num, P_nic $Report.Hostname = $_.Name $Report.version =$_.Config.Product.Version $Report.Build =$_.Config.Product.Build $Report.manufacture =$_.Hardware.SystemInfo.Vendor $Report.Model =$_.Hardware.SystemInfo.Model $Report.cpu_model =$_.Summary.Hardware.CpuModel $Report.core_num =$_.Hardware.CpuInfo.NumCpuCores $Report.ip_address =$_.Config.Network.ConsoleVnic[0].Spec.ip.ipaddress $Report.vmotion_ip =$_.Config.Vmotion.IpConfig.IpAddress $Report.HBA_num =$_.Summary.Hardware.NumHBAs $Report.P_nic =$_.Config.Network.Pnic.count $HostReport += $Report } $HostReport | Export-Csv "C:\HostReport.csv" -NoTypeInformation
hi Lucd,
This script works perfectly on ESX 3.5.
But in ESX 2.5, 3 and 4 it doesn't give values for Service console IP, vMotion IP and HBA count.
Any ideas?
hi Jeevenj,
i get this error while running your script. Cannot index into a null array. At :line:12 char:51 + $Report.ip_address =$_.Config.Network.ConsoleVnic[0].Spec.ip.ipaddress
Try this
Connect-VIServer <server> -User <user> -Password <password> $HostReport = @() Get-VMHost |Get-View |%{ $Report = "" | select Hostname, version, Build, manufacture, Model,cpu_model, core_num, ip_address,vmotion_ip, HBA_num, P_nic $Report.Hostname = $_.Name $Report.version =$_.Config.Product.Version $Report.Build =$_.Config.Product.Build $Report.manufacture =$_.Hardware.SystemInfo.Vendor $Report.Model =$_.Hardware.SystemInfo.Model $Report.cpu_model =$_.Summary.Hardware.CpuModel $Report.core_num =$_.Hardware.CpuInfo.NumCpuCores if($Report.version -like "3.5.*"){ $Report.ip_address =$_.Config.Network.ConsoleVnic.Spec.ip.ipaddress } else {$Report.ip_address =$_.Config.Network.ConsoleVnic[0].Spec.ip.ipaddress} $Report.vmotion_ip =$_.Config.Vmotion.IpConfig.IpAddress $Report.HBA_num =$_.Summary.Hardware.NumHBAs $Report.P_nic =$_.Config.Network.Pnic.count $HostReport += $Report } $HostReport | Export-Csv "C:\HostReport.csv" –NoTypeInformation
Let me know if you find any empty parameter.
Works ok on ESX 4 for me.
For the HBA count I only select the FC HBAs, if you want to see other HBAs you can leave out the Where cmdlet on that line.
For the console and vkernel IP address there was a typo.
This should work for ESX 4
Get-VMHost <esx-name> | Select Name, Version, Build, Manufacturer, Model, ProcessorType, NumCPU, @{N="Cores";E={($_| Get-View).Hardware.CpuInfo.NumCpuCores}}, @{N="Service Console IP";E={($_|Get-VMHostNetwork).ConsoleNic[0].IP}}, @{N="vMotion IP";E={($_|Get-VMHostNetwork).VirtualNic[0].IP}}, @{N="HBA count";E={($_| Get-VMHostHba | where {$_.Type -eq "FibreChannel"}).Count}}, @{N="Physical NICS count";E={($_ | Get-View).Config.Network.Pnic.Count}}
Since there are square brackets involved and since the forum SW has problems with these, I attached the script.
Unfortunately I don't have an ESX 2.5 or 3 to test.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I tested Luc's script on ESX 3.5 and it works ok.
hi Lucd,
Can you please clarify how numCpu and cores count are calculated. I assume numCpu is physical processor count and cores count is cores per physical processor.
But in the report i see for many esx host the values for numCpu and Cores count are 8 and 8. Just confused, how is it calculated?
Also i have sent you a Private Message. Please check it.
The script gets the NumCPU value from the HostSystemImpl object that is returned by Get-VMHost.
This seems indeed to return the number of cores and not the number of physical processors.
Try this
Get-VMHost <esx-name> | Select Name, Version, Build, Manufacturer, Model, ProcessorType, @{N="NumCPU";E={($_| Get-View).Hardware.CpuInfo.NumCpuPackages}}, @{N="Cores";E={($_| Get-View).Hardware.CpuInfo.NumCpuCores}}, @{N="Service Console IP";E={($_|Get-VMHostNetwork).ConsoleNic[0].IP}}, @{N="vMotion IP";E={($_|Get-VMHostNetwork).VirtualNic[0].IP}}, @{N="HBA count";E={($_| Get-VMHostHba | where {$_.Type -eq "FibreChannel"}).Count}}, @{N="Physical NICS count";E={($_ | Get-View).Config.Network.Pnic.Count}}
Now the NumCPU value is retrieved from the HostCpuInfo object.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Luc,
Now the script gives correct CPU and core values. So ESX 3.5 reporting is perfect now.
In ESX 4, now it displays values for vMotion IP and HBA count, but Service Console IP value is blank.
I have posted one more script requirement in http://communities.vmware.com/thread/262425 Please check whether do u have this script.
Strange, it gives correct results in my environment.
Are you sure the square brackets are included?
Try the attached file.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I checked whether square brackets are present. It's there.
I use VESI and also tried to execute from powercli console, but in both cases service console IP field is blank in ESX4.
I tried to attach the screenshots of the script and output, First time i got error "You are unauthorized to perform this operation, contact moderator" and message alone got posted without attachements. Tried second time but got a error "File is too large" for just 14Kb and 4kb gif files. i think forum software has a bug
Could you perhaps show the output of the following line ?
Get-VMHost <esx-hostname> | Get-VMHostNetwork | Select -ExpandProperty ConsoleNic
Run it from the PowerCLI prompt and paste in the result.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Are you running the latest PowerCLI build ?
Does
Get-PowerCLIVersion
return
PowerCLI Version ---------------- VMware vSphere PowerCLI 4.0 U1 build 208462
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Then I'm at my wits end here.
It works for me and Robert also confirmed it worked for him.
Although I can't see why this would solve the problem, you could ultimately try an upgrade to PowerShell v2 RTM.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Luc,
I can live with this script for now because my major requirement ESX3.5. I will upgrade powershell and give out a try once on ESX4. Thanks for this script, it has helped me a lot. Still i have 2 more script requirement will post it soon.
Given correct answer 10 points and helpful answers
Luc,
Need your help here. Can you please include the cluster name in the script. So the expected output looks like this.
ESX host name | Version | Build Number | Cluster Name | Manufacturer | Model | Processor Type | Physical CPU count | Cores Count | Service Console IP | vMotion IP | HBA count | Physical NICS count
If the ESX box does not belong to cluster this field can be blank.
Or, if you have a script to give out cluster wise esx host details, it is also ok for me.