25 lines
790 B
PowerShell
25 lines
790 B
PowerShell
|
#[CmdletBinding(SupportsShouldProcess)]param(
|
||
|
[CmdletBinding()]param([string[]]$MatchName,[string[]]$OrderBy,[switch]$PassThru,[string[]]$MatchAny)
|
||
|
|
||
|
$local:result = $(docker ps --format='{{ .Image }}\t{{ .Names }}\t{{ .Status }}\t{{ .Ports }}' |
|
||
|
ForEach-Object {
|
||
|
$local:l = $_ -split '\t';
|
||
|
[PSCustomObject]([ordered]@{Image=$l[0];Name=$l[1];Status=$l[2];Ports=$l[3] -replace ', ',"`n"})
|
||
|
} ) | Sort-Object Name
|
||
|
|
||
|
if( $MatchName ) {
|
||
|
$result = $result | Where-Object Name -match $($MatchName -join '|')
|
||
|
}
|
||
|
|
||
|
if( $MatchAny ) {
|
||
|
$result = $result | Where-Object { $_ | Out-String | Where-Object { $_ -match $($MatchAny -join '|') } }
|
||
|
}
|
||
|
|
||
|
if( $OrderBy ) {
|
||
|
$result = $result | Sort-Object $OrderBy
|
||
|
}
|
||
|
|
||
|
if( $PassThru ) { return $result }
|
||
|
$result | Format-Table -Wrap
|
||
|
|