title: Powershell Disk Usage Report
body: <p>I have the following script that will collect disk usage stats from remote servers.  I'm trying to get the output to display the host name rather than the IP from the .\ServerIPs.txt file the script is reading.  I have tried a retrieve the "SystemName" from get-wmiobject Win32_LogicalDisk but could not get the name to display.  What should I add to allow the host name to be displayed in the report rather than the host IP address?</p>
  
  <pre><code>$erroractionpreference = "SilentlyContinue" 
  $a = New-Object -comobject Excel.Application 
  $a.visible = $True  
  
  $b = $a.Workbooks.Add() 
  $c = $b.Worksheets.Item(1) 
  
  $c.Cells.Item(1,1) = "Server Name" 
  $c.Cells.Item(1,2) = "Drive" 
  $c.Cells.Item(1,3) = "Total Size (GB)" 
  $c.Cells.Item(1,4) = "Free Space (GB)" 
  $c.Cells.Item(1,5) = "Free Space (%)" 
  
  $d = $c.UsedRange 
  $d.Interior.ColorIndex = 19 
  $d.Font.ColorIndex = 11 
  $d.Font.Bold = $True 
  
  $intRow = 2 
  
  $colComputers = get-content ".\ServerIPs.txt" 
  foreach ($strComputer in $colComputers) 
  { 
    $colDisks = get-wmiobject Win32_LogicalDisk -computername $strComputer -Filter "DriveType = 3"  
    foreach ($objdisk in $colDisks) 
    { 
      $c.Cells.Item($intRow, 1) = $strComputer.ToUpper() 
      $c.Cells.Item($intRow, 2) = $objDisk.DeviceID 
      $c.Cells.Item($intRow, 3) = "{0:N0}" -f ($objDisk.Size/1GB) 
      $c.Cells.Item($intRow, 4) = "{0:N0}" -f ($objDisk.FreeSpace/1GB) 
      $c.Cells.Item($intRow, 5) = "{0:P0}" -f ([double]$objDisk.FreeSpace/[double]$objDisk.Size) 
      $intRow = $intRow + 1 
    } 
  }
  </code></pre>