I added the following. But not sure what I'm missing. I get the following in PowerCLI when running it.
Key : N
Value : CPUGHzCapacity
Name : N
Key : E
Value : [math]::Round($_.CpuTotalMhz/1000,2)
Name : E
Key : N
Value : CPUGHzUsed
Name : N
Key : E
Value : [math]::Round($_.CpuUsageMhz/1000,2)
Name : E
Key : N
Value : CPUGHzFree
Name : N
Key : E
Value : [math]::Round(($_.CpuTotalMhz - $_.CpuUsageMhz)/1000,2)
Name : E
Key : N
Value : MemoryCapacityGB
Name : N
Key : E
Value : [math]::Round($_.MemoryTotalGB,2)
Name : E
Key : N
Value : MemoryUsedGB
Name : N
Key : E
Value : [math]::Round($_.MemoryUsageGB,2)
Name : E
Key : N
Value : MemoryFreeGB
Name : N
Key : E
Value : [math]::Round(($_.MemoryTotalGB - $_.MemoryUsageGB),2)
Name : E
My changes
########### Connect VCs from VC_List.txt ############
$VCs= Get-Content ($SCRIPT_PARENT + "\vc_list.txt") -ErrorAction SilentlyContinue # mention vcenter name where you want to check resources.
# $VCs= Get-Content -Path N:\Scripts\VMWare\Storage_Report_HTML\vc_list.txt
$D = get-date -uformat "%m-%d-%Y-%H:%M" # To get a current date.
Write-Host "Connecting to VC" -foregroundcolor yellow
#*****************************************
foreach($vc in $VCs)
{
Connect-VIServer $VC -WarningAction 0
$outputfile = ($SCRIPT_PARENT + "\Report\$($VC).html") #".\Report\$($VC).html"
Write-Host ""
Write-Host "Collecting details from $VC" -foregroundcolor green
$Result = @()
$Result += Get-View -ViewType Datastore | Where-Object {$_.Name -notmatch "pag"} | Select-Object -Property Name,
@{N="FreeSpaceGB";E={[Math]::Round($_.Summary.FreeSpace/1GB,0)}},
@{N="CapacityGB"; E={[Math]::Round($_.Summary.Capacity/1GB,0)}},
@{N="ProvisionedSpaceGB";E={[Math]::Round(($_.Summary.Capacity - $_.Summary.FreeSpace + $_.Summary.Uncommitted)/1GB,0)}},
@{N="FreeSpace";E={[math]::Round(((100* ($_.Summary.FreeSpace/1GB))/ ($_.Summary.Capacity/1GB)),0)}} | sort -Property "FreeSpace"
@{N="CPUGHzCapacity";E={[math]::Round($_.CpuTotalMhz/1000,2)}},
@{N="CPUGHzUsed";E={[math]::Round($_.CpuUsageMhz/1000,2)}},
@{N="CPUGHzFree";E={[math]::Round(($_.CpuTotalMhz - $_.CpuUsageMhz)/1000,2)}},
@{N="MemoryCapacityGB";E={[math]::Round($_.MemoryTotalGB,2)}},
@{N="MemoryUsedGB";E={[math]::Round($_.MemoryUsageGB,2)}},
@{N="MemoryFreeGB";E={[math]::Round(($_.MemoryTotalGB - $_.MemoryUsageGB),2)}}
$HTML = '<style type="text/css">
#Header{font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;width:100%;border-collapse:collapse;}
#Header td, #Header th {font-size:14px;border:1px solid #98bf21;padding:3px 7px 2px 7px;}
#Header th {font-size:14px;text-align:center;padding-top:5px;padding-bottom:4px;background-color:#cccccc;color:#000000;}
#Header tr.alt td {color:#000;background-color:#EAF2D3;}
</Style>'
$HTML += "<HTML><BODY><Table border=1 cellpadding=0 cellspacing=0 id=Header><caption><font size=3 color=green><h1 align=""center"">~$VC-DataStore Verification Report~ </h1></font>
<h4 align=""right""><font size=3 color=""#00008B"">Date: $D </font></h4></caption>
<TR>
<TH><B>DataStore Name</B></TH>
<TH><B>Free Space (GB)</B></TD>
<TH><B>Capacity (GB)</B></TH>
<TH><B>Provisioned Space (GB)</B></TH>
<TH><B>Free Space (%)</B></TH>
<TH><B>CPU GHz Capacity (MHz)</B></TH>
<TH><B>CPU GHz Free (MHz)</B></TD>
<TH><B>CPU GHz Used (MHz)</B></TH>
<TH><B>Memory Capacity (GB)</B></TH>
<TH><B>MemoryFree (GB)</B></TD>
<TH><B>Memory Used (GB)</B></TH>
</TR>"
Foreach($Entry in $Result)
{
if($Entry.FreeSpace -lt "20")
{
$HTML += "<TR bgColor=Red>"
}
else
{
$HTML += "<TR>"
}
$HTML += "
<TD>$($Entry.Name)</TD>
<TD>$($Entry.FreeSpaceGB)</TD>
<TD>$($Entry.CapacityGB)</TD>
<TD>$($Entry.ProvisionedSpaceGB)</TD>
<TD>$($Entry.FreeSpace)</TD>
<TD>$($Entry.CPUGHzCapacity)</TD>
<TD>$($Entry.CPUGHzUsed)</TD>
<TD>$($Entry.CPUGHzFree)</TD>
<TD>$($Entry.MemoryCapacityGB)</TD>
<TD>$($Entry.MemoryUsedGB)</TD>
<TD>$($Entry.MemoryFreeGB)</TD>
</TR>"
}
$HTML += "</Table></BODY></HTML>"
$HTML | Out-File $OutputFile