title: How to sum only 2nd column values using powershell?
body: <h1>sharesize.ps1</h1>
  <pre><code>echo &quot; &quot;
  $date1 = Get-Date
  Write-Host -foreground Yellow -background Black &quot;Script Started at $date1&quot;
  
  $path = &quot;\*&quot;
  
  get-childitem $path | where {$_.PSIsContainer} | foreach { 
  
  $size = (Get-ChildItem $_ -recurse | where {!$_.PSIsContainer} | Measure-Object -Sum Length).Sum 
  
  $size = &quot;{0:N2}&quot; -f ($size / 1MB) + &quot; MB&quot;
  
  $obj = new-object psobject 
  add-member -inp $obj noteproperty Path $_.fullName 
  add-member -inp $obj noteproperty &quot;Size(MB)&quot; $size 
  [array]$report += $obj
  }
  
  
  #display the table
  $a = &quot;&lt;style&gt;&quot;
  $a = $a + &quot;BODY{background-color:green;}&quot;
  $a = $a + &quot;TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}&quot;
  $a = $a + &quot;TH{border-width: 2px;padding: 0px;border-style: solid;border-color: black;background-color:Yellow; font-family: Arial; font-size: 12pt}&quot;
  $a = $a + &quot;TD{border-width: 2px;padding: 2px 6px 2px 3px;border-style: solid;border-color: black;background-color:Azure; font-family: Arial; font-size: 10pt}&quot;
  $a = $a + &quot;&lt;/style&gt;&quot;
  
  
  $report | Sort 'Size' -Descending | ConvertTo-HTML -head $a -title &quot;Process Information&quot; -body &quot;&lt;H2&gt;Service Information&lt;/H2&gt;&quot;| Out-File -Append c:\temp\folder.html
  
  
  $date2 = Get-Date
  echo &quot; &quot;
  Write-Host -foreground Yellow -background Black &quot;Script Ended at $date2&quot;
  echo &quot; &quot;
  </code></pre>
  <hr />
  <p>Above code is working great to me, help is much appreciated for the below help.</p>
  <p>Here my requirement is to add sum of 2nd column volues and append the output to the last line of the above code output html(c:\temp\folder.html) as,</p>
  <hr />
  <pre><code>       Path                   | Size(MB)
  </code></pre>
  <hr />
  <pre><code> C:\NVIDIA\Displaydriver      |  400 MB
    *                           |  860 MB
    *                           |  100 MB
    *                           |   * MB
    *                           |   * MB
  </code></pre>
  <hr />
  <pre><code>       Total                  |  1000 MB(sum of all numbers in 2nd column values)
  </code></pre>
  <hr />
  <p>and also i need to align the 2nd column values and Total row to CENTER.</p>
  <p>Please Help</p>