PowerShell_Scripts/dps.ps1

13 lines
525 B
PowerShell

#[CmdletBinding(SupportsShouldProcess)]param(
[CmdletBinding()]param([string[]]$OrderBy,[switch]$PassThru)
$local:result = $(docker ps --format='{{ .Image }}\t{{ .Names }}\t{{ .Status }}\t{{ .Ports }}' | ForEach-Object { $local:l = $_ -split '\t'; [PSCustomObject](@{Image=$l[0];Names=$l[1];Status=$l[2];Ports=$l[3] -replace ', ',"
"}) } ) | Sort-Object Names
if( $OrderBy ) {
$result = $result | Sort-Object $OrderBy
}
if( $PassThru ) { return $result }
$result | Format-Table -Wrap -Property Image,Names,Status,Ports