Get memory allocated based on OS
The following Power-CLI command will evaluate a specific cluster and return the ratio of memory utilisation between Windows and Red Hat Linux virtual machines.
1# Variable settings
2$clusterName = "insert cluster name"
3
4$winVMs = Get-Cluster $clusterName | Get-VM | ? {$_.Guest.OSFullName -like 'Microsoft Windows Server*'} | Select Name, PowerState, MemoryGB
5
6$lnxVMs = Get-Cluster $clusterName | Get-VM | ? {$_.Guest.OSFullName -like 'Red Hat*'} | Select Name, PowerState, MemoryGB
7
8foreach($winVM in $winVMs){ $winMemTotal += $winVM.MemoryGB }
9foreach($lnxVM in $lnxVMs){ $lnxMemTotal += $lnxVM.MemoryGB }
10
11$memTotal = $winMemTotal + $lnxMemTotal
12$winMemSplit = $winMemTotal / $memTotal
13$winMemSplit *= 100
14$winMemSplit = [math]::Round($winMemSplit)
15$lnxMemSplit = $lnxMemTotal / $memTotal
16$lnxMemSplit *= 100
17$lnxMemSplit = [math]::Round($lnxMemSplit)
18
19"Windows memory total is " + [math]::Round($winMemTotal) + "GB"
20"Linux memory total is " + [math]::Round($lnxMemTotal) + "GB"
21"The split between Windows and Linux is... Windows " + $winMemSplit + "% to Linux " + $lnxMemSplit + "%"
comments powered by Disqus