Skip to content

Commit 8ec066a

Browse files
committed
🚸 Filter out more noise drives; improve appearance
1 parent f3bcb3e commit 8ec066a

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

‎Show-PSDriveUsage.ps1‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ Write-Info.ps1
2121
Show-PSDriveUsage.ps1 C -AsAscii
2222
2323
#################_______________________________________________________________________
24-
C:\ Windows (953GB, NTFS, Fixed) 762GB (79%) free, 191GB (20%) used
24+
C:\ Windows [NTFS] 953GB = 762GB (79%) free + 191GB (20%) used
25+
26+
.EXAMPLE
27+
Show-PSDriveUsage.ps1 /home -AsAscii
28+
###################_____________________________________________________________________
29+
/home [ext3] 4TB = 3TB (73%) free + 792GB (21%) used
2530
#>
2631

2732
#Requires -Version 7
@@ -41,7 +46,6 @@ Begin
4146
[Parameter(ValueFromPipelineByPropertyName=$true)][string] $Name,
4247
[Parameter(ValueFromPipelineByPropertyName=$true)][string] $VolumeLabel,
4348
[Parameter(ValueFromPipelineByPropertyName=$true)][string] $DriveFormat,
44-
[Parameter(ValueFromPipelineByPropertyName=$true)][IO.DriveType] $DriveType,
4549
[Parameter(ValueFromPipelineByPropertyName=$true)][IO.DirectoryInfo] $RootDirectory,
4650
[Parameter(ValueFromPipelineByPropertyName=$true)][long] $TotalSize,
4751
[Parameter(ValueFromPipelineByPropertyName=$true)][long] $TotalFreeSpace,
@@ -64,11 +68,17 @@ Begin
6468
}
6569
Write-Info.ps1 $usedgraph -fg Cyan -NoNewLine
6670
Write-Info.ps1 $freegraph -fg DarkCyan
67-
Write-Info.ps1 "$Name $VolumeLabel ($size, $DriveFormat, $DriveType) $free ($freepercent%) free, $used ($usedpercent%) used" -fg $color
71+
$fqdn = $Name -ne $VolumeLabel ? "$Name $VolumeLabel [$DriveFormat]" : "$Name [$DriveFormat]"
72+
Write-Info.ps1 "$fqdn $size = $free ($freepercent%) free + $used ($usedpercent%) used" -fg $color
6873
}
6974
}
7075
Process
7176
{
7277
if($Name) {$Name |ForEach-Object {[IO.DriveInfo] $_} |Show-DriveUsage}
73-
else {[IO.DriveInfo]::GetDrives() |Where-Object {$_.DriveType -eq 'Fixed' -and $_.IsReady} |Show-DriveUsage}
78+
else
79+
{
80+
[IO.DriveInfo]::GetDrives() |
81+
Where-Object {$_.DriveType -eq 'Fixed' -and $_.IsReady -and $_.TotalSize -gt 0} |
82+
Show-DriveUsage
83+
}
7484
}

0 commit comments

Comments
 (0)