PowerShell_Scripts/zfs/Get-ZfsItem.ps1

26 lines
836 B
PowerShell

[CmdletBinding()]param(
[string[]]$Options='name,used,avail,refer,canmount,mounted,mountpoint'
)
$Options = $Options -join ','
if( $options -split ',' -notcontains 'name' ) { $options = "name,$Options" }
$local:prev = '';
zfs list -o $Options |
ForEach-Object { $_ -replace ' +',"`t" } |
ConvertFrom-Csv -Delimiter "`t" |
Where-Object Name -NotMatch '^rpool/var/lib/docker/' |
ForEach-Object {
$local:o = $_ | Select-Object @{L='-';E={''}},*
$local:tmpPrev = $o.Name -replace '^(\w+(\W\w+(\W\w+)?)?).*','$1';
if( $tmpPrev -notmatch "^$prev" -and $prev -notin ('','NAME') ) {
$o.'-' = "`n-"
};
$prev = $tmpPrev;
if( $o.MOUNTPOINT ) {
$o.MOUNTPOINT = $o.MOUNTPOINT -replace '^none$','<none>'
}
$o
} |
Format-Table -Wrap