title: PowerShell 2.0 Disk Space check
body: <p>Below is the code for checking the disk space:</p>
  
  <pre><code>$disks = Get-WmiObject -ComputerName WDSMS01 -Namespace root\cimv2 -Query "Select * from Win32_LogicalDisk where DriveType=3"
  
  $disks.DeviceID
  $dsql01 = @()
  
  foreach($db in $disks)
  {
      $dsql = New-Object PSObject
      $dsql | Add-Member -MemberType NoteProperty -Name "Drive Name" -value $db.DeviceID
      $dsql | Add-Member -MemberType NoteProperty -Name "Total Space(GB)" -value ($db.Size/1GB)
      $dsql | Add-Member -MemberType NoteProperty -Name "Free Space(GB)" -value ($db.FreeSpace/1GB)
      $dsql01 += $dsql
  }
  
  $dsql01
  </code></pre>
  
  <p>Is it possible to limit the decimals by 2 digits? Also, add another column that computes free space in % format.</p>
  
  <p>Thanks.</p>