Script directory for a PowerShell profile. https://blog.lksz.me/keeping-track-of-everything/#-mypsscriptroot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.3 KiB

  1. param([ValidateSet('KB','GB','TB')]$SizeUnitName = 'GB')
  2. $local:zpool_cmd = $null
  3. $local:excludeType = ''
  4. $script:SizeUnit = Invoke-Expression "1$SizeUnitName"
  5. $script:SizeRound = 2
  6. $SizeUnit /= 1KB
  7. function NewDataRow{param($Size,$Used,$Available,$Percent,$Source,$FSType,$Target)
  8. [PSCustomObject]@{
  9. "Size$SizeUnitName" = [Math]::Round($Size /$SizeUnit, $SizeRound)
  10. "Used$SizeUnitName" = [Math]::Round($Used /$SizeUnit, $SizeRound)
  11. "Available$SizeUnitName" = [Math]::Round($Available/$SizeUnit, $SizeRound)
  12. 'Used%' = [int]($Percent -replace '%$','')
  13. Source = $Source
  14. FSType = $FSType
  15. Target = $Target
  16. }
  17. }
  18. $local:df = @()
  19. & df '--output=size,used,avail,pcent,source,fstype,target' |
  20. Select-Object -Skip 1 | ForEach-Object {
  21. $local:df = $_.Split(' ', [StringSplitOptions]::RemoveEmptyEntries)
  22. NewDataRow $df[0] $df[1] $df[2] $df[3] $df[4] $df[5] $df[6]
  23. } | Where-Object {
  24. -not ($_.FSType -eq 'zfs' -and $_.Source -match '/')
  25. } | Sort-Object -Property Target
  26. #$zpool_cmd = get-command zpool | Where-Object CommandType -eq 'Application' | Select-Object -ExpandProperty Source
  27. #if( $zpool_cmd ) {
  28. # $excludeType = '--exclude-type=zfs'
  29. #}