title: Powershell - Mulitple Servers CPU/Mem/C Drive stats - Total Average
body: <p>Newbie here, :-)</p>
  
  <p>Hope you all well and to reach out for some assistance;</p>
  
  <p>I have a code also which can generate CPU/Mem/C Drive stats for multiple servers, and was hoping to ask for help if this could have a total average of all the servers? with the script below, is there a way to include getting the total average of all the servers I have gathered (e.g. 10 servers)?</p>
  
  <pre><code>$ServerListFile = "D:\serverList.txt"  
  $ServerList = Get-Content $ServerListFile -ErrorAction SilentlyContinue 
  $Result = @() 
  ForEach($computername in $ServerList) 
  {
  
  $AVGProc = Get-WmiObject -computername $computername win32_processor | 
  Measure-Object -property LoadPercentage -Average | Select Average
  $OS = gwmi -Class win32_operatingsystem -computername $computername |
  Select-Object @{Name = "MemoryUsage"; Expression = {“{0:N2}” -f ((($_.TotalVisibleMemorySize - $_.FreePhysicalMemory)*100)/ $_.TotalVisibleMemorySize) }}
  $vol = Get-WmiObject -Class win32_Volume -ComputerName $computername -Filter "DriveLetter = 'C:'" |
  Select-object @{Name = "C PercentFree"; Expression = {“{0:N2}” -f  (($_.FreeSpace / $_.Capacity)*100) } }
  
  $result += [PSCustomObject] @{ 
  ServerName = "$computername"
  CPULoad = "$($AVGProc.Average)%"
  MemLoad = "$($OS.MemoryUsage)%"
  CDrive = "$($vol.'C PercentFree')%"
  }
  $Outputreport = "&lt;HTML&gt;&lt;TITLE&gt; Server Health Report &lt;/TITLE&gt;
               &lt;BODY background-color:peachpuff&gt;
               &lt;font color =""#99000"" face=""Microsoft Tai le""&gt;
               &lt;H2&gt; Server Health Report &lt;/H2&gt;&lt;/font&gt;
               &lt;Table border=1 cellpadding=0 cellspacing=0&gt;
               &lt;TR bgcolor=gray align=center&gt;
                 &lt;TD&gt;&lt;B&gt;Server Name&lt;/B&gt;&lt;/TD&gt;
                 &lt;TD&gt;&lt;B&gt;Avrg.CPU Utilization&lt;/B&gt;&lt;/TD&gt;
                 &lt;TD&gt;&lt;B&gt;Memory Utilization&lt;/B&gt;&lt;/TD&gt;
                 &lt;TD&gt;&lt;B&gt;Drive C Free Space&lt;/B&gt;&lt;/TD&gt;
                 &lt;/TR&gt;"
  
  Foreach($Entry in $Result) 
  
      { 
    if(($Entry.CpuLoad) -or ($Entry.memload) -ge "80") 
    { 
      $Outputreport += "&lt;TR bgcolor=white&gt;" 
    } 
    else
     {
      $Outputreport += "&lt;TR&gt;" 
    }
    $Outputreport += "&lt;TD&gt;$($Entry.Servername)&lt;/TD&gt;&lt;TD align=center&gt;$($Entry.CPULoad)&lt;/TD&gt;&lt;TD align=center&gt;$($Entry.MemLoad)&lt;/TD&gt;&lt;TD align=center&gt;$($Entry.CDrive)&lt;/TD&gt;&lt;/TR&gt;" 
  }
   $Outputreport += "&lt;/Table&gt;&lt;/BODY&gt;&lt;/HTML&gt;" 
   } 
  
  $Outputreport | out-file "D:\Result $(Get-Date -Format yyy-mm-dd-hhmm).htm"
  </code></pre>