hl2guide

Drive Statistics Lister 1.0A - PowerShell

Jan 6th, 2018
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Drive Statistics Lister
  2. # Lists Drives and Space Info [Letter, Drive Name, Free (GBs), Size (GBs)]
  3. # Version: 1.0A
  4.  
  5. # Displays a "Drive Stats:" Message
  6. Write-Host
  7. Write-Host 'Drive Stats:' -ForegroundColor Yellow
  8.  
  9. # Gets the drive information (excluding 0 MB drives)
  10. $driveInformation = Get-WmiObject win32_logicaldisk | Where-Object {$_.Size -gt 0}
  11.  
  12. # Displays the data in a formatted table
  13. $driveInformation | Format-Table @{Expression={$_.DeviceId};Label='Letter'},
  14. @{Expression={$_.VolumeName};Label='Name'},
  15. @{n='Free (GBs)';e={[math]::Round($_.FreeSpace/1GB,2)}},
  16. @{n='Size (GBs)';e={[math]::Round($_.Size/1GB,2)}}
Advertisement
Add Comment
Please, Sign In to add comment