ContainerInfo/Get-NavContainers.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<#
 .Synopsis
  Get a list of all NAV Containers
 .Description
  Returns the names of all NAV Containers
 .Example
  Get-NavContainers | Remove-NavContainer
#>

function Get-NavContainers {
    Process {
        docker ps -a -q --no-trunc | % {
            $inspect = docker inspect $_ | ConvertFrom-Json
            if ($inspect.Config.Labels.psobject.Properties.Match('nav').Count -ne 0) {
                $name = $inspect.Name
                if ($name.startsWith('/')) {
                    $name.subString(1)
                } else {
                    $name
                }
            }
        }
    }
}
Export-ModuleMember -function Get-NavContainers