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.

25 lines
790 B

  1. #[CmdletBinding(SupportsShouldProcess)]param(
  2. [CmdletBinding()]param([string[]]$MatchName,[string[]]$OrderBy,[switch]$PassThru,[string[]]$MatchAny)
  3. $local:result = $(docker ps --format='{{ .Image }}\t{{ .Names }}\t{{ .Status }}\t{{ .Ports }}' |
  4. ForEach-Object {
  5. $local:l = $_ -split '\t';
  6. [PSCustomObject]([ordered]@{Image=$l[0];Name=$l[1];Status=$l[2];Ports=$l[3] -replace ', ',"`n"})
  7. } ) | Sort-Object Name
  8. if( $MatchName ) {
  9. $result = $result | Where-Object Name -match $($MatchName -join '|')
  10. }
  11. if( $MatchAny ) {
  12. $result = $result | Where-Object { $_ | Out-String | Where-Object { $_ -match $($MatchAny -join '|') } }
  13. }
  14. if( $OrderBy ) {
  15. $result = $result | Sort-Object $OrderBy
  16. }
  17. if( $PassThru ) { return $result }
  18. $result | Format-Table -Wrap