http://blogs.msdn.com/powershell/archive/2009/10/15/introducing-the-windows-7-resource-kit-powershell-pack.aspx
It follows my disk free version. I'm using mounted volumes and I have to watch for free space on my partitions.
$outData = @("")
$server = $args[0]
$dataFromServer = Get-WmiObject Win32_Volume -ComputerName '.' | Select-Object SystemName,Label,Name,DriveLetter,DriveType,Capacity,Freespace
# Formatting
$size = @{ l = "Size (GB)"; e = { $_.Capacity/1gb}; f = "{0:0.0}"}
$free = @{ l = "free (GB)"; e = { $_.Freespace/1gb}; f = "{0:0.0}"}
$perc = @{ l = "percent"; e = { 100.0 * ([double]$_.freespace/[double]$_.Capacity)}; f="{0:00.0}" }
$name = @{ e = "Label"; f = "{0,-10}" }
$fields = $name,$size,$free,$perc
foreach ($currline in $dataFromServer) {
if ((-not $currline.name.StartsWith("\\")) -and ($currline.Drivetype -ne 5)) {
[float]$tempfloat = ($currline.Freespace / 1000000) / ($currline.Capacity / 1000000)
$temppercent = [math]::round(($tempfloat * 100),2)
add-member -InputObject $currline -MemberType NoteProperty -name FreePercent -value "$temppercent %"
$outData = $outData + $currline
}
}
$outData | sort-object -property Label | format-table $fields -auto
# Select-Object Label,Capacity,Freespace, FreePercent
#| sort-object -property FreePercent | format-table -autosize
# http://mspowershell.blogspot.com/2007/12/script-to-extract-disk-space-usage.html
# http://jtruher.spaces.live.com/blog/cns!7143DA6E51A2628D!138.entry
Keine Kommentare:
Kommentar veröffentlichen