Hi All,
Firstly, big ups to LucD for the awesome script below:
$report = @()
$clusterName = "*"
foreach($cluster in Get-Cluster -Name $clusterName){
$esx = $cluster | Get-VMHost
$ds = Get-Datastore -VMHost $esx | where {$_.Type -eq "VMFS" -and $_.Extensiondata.Summary.MultipleHostAccess}
$row = "" | Select VCname,DCname,Clustername,"Total Physical Memory (MB)",
"Configured Memory MB","Available Memroy (MB)",
"Total CPU (Mhz)","Configured CPU (Mhz)",
"Available CPU (Mhz)","Total Disk Space (MB)",
"Configured Disk Space (MB)","Available Disk Space (MB)"
$row.VCname = $cluster.Uid.Split(':@')[1]
$row.DCname = (Get-Datacenter -Cluster $cluster).Name
$row.Clustername = $cluster.Name
$row."Total Physical Memory (MB)" = ($esx | Measure-Object -Property MemoryTotalMB -Sum).Sum
$row."Configured Memory MB" = ($esx | Measure-Object -Property MemoryUsageMB -Sum).Sum
$row."Available Memroy (MB)" = ($esx | Measure-Object -InputObject {$_.MemoryTotalMB - $_.MemoryUsageMB} -Sum).Sum
$row."Total CPU (Mhz)" = ($esx | Measure-Object -Property CpuTotalMhz -Sum).Sum
$row."Configured CPU (Mhz)" = ($esx | Measure-Object -Property CpuUsageMhz -Sum).Sum
$row."Available CPU (Mhz)" = ($esx | Measure-Object -InputObject {$_.CpuTotalMhz - $_.CpuUsageMhz} -Sum).Sum
$row."Total Disk Space (MB)" = ($ds | where {$_.Type -eq "VMFS"} | Measure-Object -Property CapacityMB -Sum).Sum
$row."Configured Disk Space (MB)" = ($ds | Measure-Object -InputObject {$_.CapacityMB - $_.FreeSpaceMB} -Sum).Sum
$row."Available Disk Space (MB)" = ($ds | Measure-Object -Property FreeSpaceMB -Sum).Sum
$report += $row
}
$report | Export-Csv "C:\SS\Cluster-Report.csv" -NoTypeInformation -UseCulture
I would just like to change a few things, but not quite sure where to put the details. The script currently displays all the data in MB, what can I do to change it to GB?
Thanks
To go from MB to GB you can divide by the predefined constant 1KB
$row."Configured Disk Space (TB)" = ($ds | Measure-Object -InputObject {$_.CapacityMB - $_.FreeSpaceMB} -Sum).Sum/1KB
$row."Available Disk Space (TB)" = ($ds | Measure-Object -Property FreeSpaceMB -Sum).Sum/1KB
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
To go from MB to GB you can divide by the predefined constant 1KB
$row."Configured Disk Space (TB)" = ($ds | Measure-Object -InputObject {$_.CapacityMB - $_.FreeSpaceMB} -Sum).Sum/1KB
$row."Available Disk Space (TB)" = ($ds | Measure-Object -Property FreeSpaceMB -Sum).Sum/1KB
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I just noticed the thread title says MB to TB.
In that case divide by 1MB instead of 1KB
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks so much LucD, helpful as always.
Cheers