As for which version of PowerCLI to use, you should be fine using 6.5 based on the interop matrix: VMware Product Interoperability Matrixes
If you're looking to modify the code yourself, here's the documentation for PowerCLI, it's really powerful and if you have the free time I'd definitely recommend diving in: VMware PowerCLI Documentation
Something like what Arjun recommended should work, but I think the host data you're looking for was missing and it may be difficult to follow what's happening if you're just starting with PowerCLI. Since it sounds like you may be looking for something to help you start making or customizing your own scripts, here's something I threw together in an attempt to make it easy enough to follow:
$VIServer = "vCenterName"
$vmLocation = "Cluster/Datacenter"
$hostArr = @()
$vmArr = @()
If (!(Get-Module | Where {$_.Name -eq "VMware.VimAutomation.Core"})) {
Import-Module "VMware.VimAutomation.Core" -ErrorAction SilentlyContinue
}
Connect-VIServer $VIServer
ForEach ($vmHost in (Get-VMHost -Location $vmLocation)) {
$vmHost = $vmHost | Select Name,ProcessorType,NumCpu,Model
$hostArr += $vmHost
ForEach ($vm in (Get-VM -Location $vmHost)) {
$vm = Get-VM -Name $VMName | Select Name,PowerState,NumCpu
$vmArr += $VM
}
}
To help with following what's happening: Up top, the variables are being used to define what vCenter we connect to, what location we pull VMs from on that vCenter. $vmArr/$hostArr = @() is just being used to initialize our array variables. Next we're checking for/adding the module for PowerCLI. After that we connect to the vCenter (defined by the $VIServer variable). Finally, we loop through the hosts then VMs we want, grabbing info from each, then tossing that info into the arrays.
Basically, just adjust those 3 variables at the top as needed, and this will get you two arrays with the data you're looking for. The question is, what do you want to do with that data once you have it? I'd suggest determining what you want to get out of the info, and working from here to manipulate this code to give you what you need to see.
So you can either manipulate the data further, or export it as is. Since it's in two arrays, that's two exports. If you'd like a couple csv files for example, this would work (of course, adjust the location it's exporting to as needed):
$vmArr | Export-Csv -NoTypeInformation "C:\Users\username\Desktop\vmCpu.csv"
$hostArr | Export-Csv -NoTypeInformation "C:\Users\username\Desktop\hostCpu.csv"
Finally, we can go further, such as setting this up to e-mail these CSV files out, or put them on a network share, overwriting each time, so you have a location with up to date data on each script run. We could then save the script and make it a scheduled task on the machine with PowerCLI, so you could have this run on a regular basis.
~LikeABrandit