title: Sum Columns Using Powershell
body: <p>I have written the following PowerShell script for getting disk space information for servers in our environment. </p>
  
  
  
  <pre class="lang-powershell prettyprint-override"><code>$servers = Get-Content E:\POC.txt
  $array = @()
  foreach($server in $servers){
      $sysinfo =  Get-WmiObject Win32_Volume -ComputerName $server
      for($i = 0;$i -lt $sysinfo.Count; $i++){
          $sname =  $sysinfo[$i].SystemName
          $servername = $server
          $label = $sysinfo[$i].Label
          if(($label) -and (!($label.Contains("FILLER")))){
              write-host "Processing $label from $server"
              $name = $sysinfo[$i].Name
              $capacity = [math]::round(($sysinfo[$i].Capacity/1GB),2)
              $fspace = [math]::round(($sysinfo[$i].FreeSpace/1GB),2)
              $sused = [math]::round((($sysinfo[$i].Capacity - $sysinfo[$i].FreeSpace)/1GB),2)
              $fspacepercent =  [math]::Round((($sysinfo[$i].FreeSpace*100)/$sysinfo[$i].Capacity),2)
              $obj = New-Object PSObject
              $obj | Add-Member -MemberType NoteProperty -Name "SystemName" -Value $sname
              $obj | Add-Member -MemberType NoteProperty -Name "ServerName" -Value $server
              $obj | Add-Member -MemberType NoteProperty -Name "Label" -Value $label
              $obj | Add-Member -MemberType NoteProperty -Name "Name" -Value $name
              $obj | Add-Member -MemberType NoteProperty -Name "Capacity(GB)" -Value $capacity
              $obj | Add-Member -MemberType NoteProperty -Name "FreeSpace(GB)" -Value $fspace
              $obj | Add-Member -MemberType NoteProperty -Name "Used(GB)" -Value $sused
              $obj | Add-Member -MemberType NoteProperty -Name "FreeSpace%" -Value $fspacepercent
              $array += $obj
          }
      }
      $array += write-output " "
      $totalSize = ($array | Measure-Object 'Capacity(GB)' -Sum).Sum
      $array += $totalsize
      $array += write-output " "
  }
  $filename = "E:\VolumeReport.csv"
  $array |  Export-CSV $filename -NoTypeInformation
  </code></pre>
  
  <p>One additional requirement here is to get the sum of the columns for Capacity, Size and Freespace for each server. I tried using Measure-Object but no success. 
  No values are getting outputted here. Just blank. Please look into this and kindly assist.</p>