Created
June 13, 2013 09:36
-
-
Save talatham/5772463 to your computer and use it in GitHub Desktop.
Display the disk usage for a specified machine.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Initialise machine name | |
$server = "<>" | |
# Get fixed drive info | |
$disks = Get-WmiObject -ComputerName $server -Class Win32_LogicalDisk -Filter "DriveType = 3"; | |
foreach($disk in $disks) | |
{ | |
$deviceID = $disk.DeviceID; | |
[float]$size = $disk.Size; | |
[float]$freespace = $disk.FreeSpace; | |
$percentFree = [Math]::Round(($freespace / $size) * 100, 2); | |
$sizeGB = [Math]::Round($size / 1073741824, 2); | |
$freeSpaceGB = [Math]::Round($freespace / 1073741824, 2); | |
Write-Host "$server,$deviceID,$sizeGB,$freeSpaceGB,$percentFree"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment