Hi Guys,
I am stucket with a script that can display usage of CPU by processor type and % of host using AMD for all host attached to a vcenter.
Is their my little script...
$TotalCpu = (Get-VMhost | where {$_.Hardware.CpuPkg[0].Description -match 'Intel'} | Measure-Object -Property CpuTotalMhz -Sum).Sum
Write-Host $TotalCpu MHZ
i also want to know if there is a way to have percentage of host using AMD and intel.
Already try that script from alan ( working great)
Get-VMHost | Sort Name | Get-View | Select Name, @{N=“Cluster“;E={Get-Cluster -VMHost (Get-VMHost $_.Name)}},@{N=“CPU“;E={$_.Hardware.CpuPkg[0].Description}}
But have no idea how to extract my precious
If someone can help ( Great Lucd are u there ?)
Thanks
You mean something like this ?
$esx = Get-VMHost
$totInt = $esx | Where{$_.ExtensionData.Hardware.CpuPkg[0].Description -match 'Intel'}
$totAMD = $esx | Where{$_.ExtensionData.Hardware.CpuPkg[0].Description -match 'AMD'}
Write-Output "Total ESXi : $($esx.Count)"
Write-Output "Total Intel: $('{0:p}' -f ($totInt/$esx.Count))"
Write-Output "Total AMD : $('{0:p}' -f ($totAMD/$esx.Count))"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You mean something like this ?
$esx = Get-VMHost
$totInt = $esx | Where{$_.ExtensionData.Hardware.CpuPkg[0].Description -match 'Intel'}
$totAMD = $esx | Where{$_.ExtensionData.Hardware.CpuPkg[0].Description -match 'AMD'}
Write-Output "Total ESXi : $($esx.Count)"
Write-Output "Total Intel: $('{0:p}' -f ($totInt/$esx.Count))"
Write-Output "Total AMD : $('{0:p}' -f ($totAMD/$esx.Count))"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Lucd,
Thanks for your reply, still got the same error ...
Impossible d'indexer dans un tableau Null.
Au niveau de D:\Desktop\amdintel.ps1 : 3 Caractère : 43
+ $totInt = $esx | Where{$_.Hardware.CpuPkg[ <<<< 0].Description -match 'Intel'}
+ CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
Au niveau de D:\Desktop\amdintel.ps1 : 4 Caractère : 43
+ $totAMD = $esx | Where{$_.Hardware.CpuPkg[ <<<< 0].Description -match 'AMD'}
+ CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
Any idea ?
Oops, forgot ExtensionData.
I updated the script above
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Still not
L'appel de la méthode a échoué parce que [System.Object[]] ne contient pas de méthode nommée « op_Division ».
Au niveau de D:\Desktop\amdintel.ps1 : 7 Caractère : 21
+ '{0:p}' -f ($totInt/ <<<< $esx.Count)
+ CategoryInfo : InvalidOperation: (op_Division:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Total Intel:
L'appel de la méthode a échoué parce que [System.Object[]] ne contient pas de méthode nommée « op_Division ».
Au niveau de D:\Desktop\amdintel.ps1 : 8 Caractère : 21
+ '{0:p}' -f ($totAMD/ <<<< $esx.Count)
+ CategoryInfo : InvalidOperation: (op_Division:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Hi,
I found the trick thanks for your help. the error ( i thought ) was about the TotInt variable ( String ) and it cannot be divided by a number ( .count)
So i modified The script like that work well :
$esx = Get-VMHost
$totInt = $esx | Where{$_.ExtensionData.Hardware.CpuPkg[0].Description -match 'Intel'}
$totAMD = $esx | Where{$_.ExtensionData.Hardware.CpuPkg[0].Description -match 'AMD'}
$Intel = $(100*$totInt.Count/$esx.Count)
$Amd = $(100*$totAMD.Count/$esx.Count)
Write-Output "Total ESXi Intel : $($totInt.Count)"
Write-Output "Total ESXi AMD : $($totAMD.Count)"
Write-Output "ESXi Intel : $Intel %"
Write-Output "ESXi AMD : $Amd % "
Thanks again great Lucd
$esx = Get-VMHost
$totInt = $esx | Where{$_.ExtensionData.Hardware.CpuPkg[0].Description -match 'Intel'}
$totAMD = $esx | Where{$_.ExtensionData.Hardware.CpuPkg[0].Description -match 'AMD'}
Write-Output "Total ESXi : $($esx.Count)"
Write-Output "Total Intel: $('{0:p}' -f ($totInt.count/$esx.Count))"
Write-Output "Total AMD : $('{0:p}' -f ($totAMD.count/$esx.Count))"
Corrected