#[CmdletBinding(SupportsShouldProcess)]param( [CmdletBinding()]param([string[]]$MatchName,[string[]]$OrderBy,[switch]$PassThru,[string[]]$MatchAny) $local:containers = [ordered]@{} $(docker ps -q) | ForEach-Object { $local:tmp = docker inspect $_ | ConvertFrom-Json; $local:tmpObj = [PSCustomObject]([ordered]@{ Name=$tmp.Name.Substring(1) Project=$tmp.Config.Labels.'com.docker.compose.project' Service=$tmp.Config.Labels.'com.docker.compose.service' Status=$tmp.State.Status Image=$tmp.Config.Image Ports=$( if( $tmp.HostConfig -and $tmp.HostConfig.PortBindings ) { $tmp.HostConfig.PortBindings | Get-Member -type NoteProperty | Select-Object -ExpandProperty Name | ForEach-Object { "$($tmp.HostConfig.PortBindings."$_".HostPort)/$_" } } ) Binds= $tmp.HostConfig.Binds raw = $tmp }) $tmpObj.PSObject.TypeNames.Insert(0,"DockerContainersOutput") $containers[$tmpObj.Name]=$tmpObj } $local:result = $containers.Values | Sort-Object Name if( $MatchName ) { $result = $result | Where-Object Name -match $($MatchName -join '|') } if( $MatchAny ) { $result = $result | Where-Object { $_ | Format-Table -Wrap -HideTableHeaders | Out-String | Where-Object { $_ -match $($MatchAny -join '|') } } } if( $OrderBy ) { $result = $result | Sort-Object $OrderBy } #if( $PassThru ) { return $result } $result #| Format-Table -Wrap