Hey Guys can you help my required . I was able to get the details esxi host cores and socket but cluster name and Vm's count
Need script for to get cluster name, esxi host name and VM's count in the cluster and last core and sockets. for licensing
Here is the script am using.
$result = @()
$vmhost = get-vmhost
foreach ($esxi in $vmhost) {
$HostCPU = $esxi.ExtensionData.Summary.Hardware.NumCpuPkgs
$HostCPUcore = $esxi.ExtensionData.Summary.Hardware.NumCpuCores/$HostCPU
$obj = new-object psobject
$obj | Add-Member -MemberType NoteProperty -Name name -Value $esxi.Name
$obj | Add-Member -MemberType NoteProperty -Name CPUSocket -Value $HostCPU
$obj | Add-Member -MemberType NoteProperty -Name Corepersocket -Value $HostCPUcore
$result += $obj
}
$result | Export-Csv esxireport.csv -NoTypeInformation -UseCulture
You forgot a comma at the end of the previous line.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Moderator: Moved to PowerCLI
You could do something like this
Select @{N='Cluster';E={$cluster.Name}}, Name,
@{N='VMonCluster';E={(Get-VM -Location $cluster).Count}},
@{N='VMonEsx';E={(Get-VM -Location $_).Count}},
@{N='CPUSocket';E={$_.ExtensionData.Summary.Hardware.NumCpuPkgs}},
@{N='Corepersocket';E={$_.ExtensionData.Summary.Hardware.NumCpuCores/$_.ExtensionData.Summary.Hardware.NumCpuPkgs}} |
Export-Csv esxireport.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Awesome and very quick response.
Hey Lucd,
Am trying to get OS version and counts of windows VM's in the environment. So just added it like below. but getting errors.
Get-Cluster -PipelineVariable cluster | Get-VMHost |
Select @{N='Cluster';E={$cluster.Name}}, Name,
@{N='VMonCluster';E={(Get-VM -Location $cluster).Count}},
@{N='VMonEsx';E={(Get-VM -Location $_).Count}},
@{N='CPUSocket';E={$_.ExtensionData.Summary.Hardware.NumCpuPkgs}},
@{N='Corepersocket';E={$_.ExtensionData.Summary.Hardware.NumCpuCores/$_.ExtensionData.Summary.Hardware.NumCpuPkgs}}
@{N='WinVM';E={(Get-VM -Location $_ | where{$_.Guest.OSFullName -match "Windows"}).Count}} |
Export-Csv esxireport.csv -NoTypeInformation -UseCulture
Which errors are you getting?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Errors :
AM expecting output is :
Cluster Name ||VMonCluster || VMonEsx || CPUSocket || Corepersocket ||Win VM's count each host || OSversion
You forgot a comma at the end of the previous line.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes got it .
and also am looking OS version.if we can add this(@{N='WinVM';E={(Get-VM -Location $_ | where{$_.Guest.OSFullName ) will works to get the OS version ?
Not really, the lowest loop is over ESXi nodes.
You can get the OS name of each VM on that ESXi node, but it could potentially be a long list.
Something like this
Select @{N='Cluster';E={$cluster.Name}}, Name,
@{N='VMonCluster';E={(Get-VM -Location $cluster).Count}},
@{N='VMonEsx';E={(Get-VM -Location $_).Count}},
@{N='CPUSocket';E={$_.ExtensionData.Summary.Hardware.NumCpuPkgs}},
@{N='Corepersocket';E={$_.ExtensionData.Summary.Hardware.NumCpuCores/$_.ExtensionData.Summary.Hardware.NumCpuPkgs}},
@{N='WinVM';E={(Get-VM -Location $_ | where{$_.Guest.OSFullName -match "Windows"}).Count}},
@{N='WinVMOS';E={(Get-VM -Location $_ | where{$_.Guest.OSFullName -match "Windows"}).OSFullName -join '|'}} |
Export-Csv esxireport.csv -NoTypeInformation -UseCulture
Or do you mean something else?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This works great on my 6.7 stuff but seems to be failing on my 7.0 stuff. Are there any changes to POWERCLI that might need to happen?
To clarify the script runs without error in both environments but does not return CPU Sockets or CoresPerSocket on my 7.0 environment.
Just tested with PowerCLI 13.0 in vSphere 7.0.3, and the values for CPU sockets and CoresPerSocket seem to be correct for me.
Which PowerShell and PowerCLI versions are you using?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am on Power CLI 12.0 . Powershell information is as follows:
PS C:\Users\gotts> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.19041.1320
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.1320
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
That is not the latest PowerCLI release, but that shouldn't cause those issues you are seeing.
What incorrect numbers do you actually see?
Are the values in the Web GUI you see for the ESXi nodes different from what the script is reporting?
Can you share an example?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I tried to upgrade PowerCLI to 13.0 but I don't think it was accomplished correctly, please advise if this is normal?
PS C:\WINDOWS\system32> get-module -ListAvailable "VMware.PowerCLI" | select version
Version
-------
12.0.0.15947286
13.0.0.20829139
12.2.0.17538434
13.0.0.20829139
I get null values, those columns are empty, for CPU Sockets and Cores on the hosts that are running 7.0 u3.
The multiple PowerCLI versions you seem to have might be the cause of the issues.
The best is to remove them all.
Check where they are located with
Get-Module -Name VMware.PowerCLI -ListAvailable
That should give you all the folders where a PowerCLI version is installed.
Then remove all the PowerCLI related folders in each of these locations.
You can do this from the File Explorer, provided none of these modules is in use (close all PS and PowerCLI sessions).
Finally, do a new Install-Module.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for the information, cleaning up my Powercli versions fixed my issue.
Blessings on you this season!