PB.Docker-Inspect.psm1

function Docker-Inspect {
    <#
    .SYNOPSIS
       Inspects Docker container on specific Host
    .EXAMPLE
        % docker-inspect (host) (container ID or Name)
    #>


[PoshBot.BotCommand(
    CommandName = 'docker-inspect',
    Aliases = ('dis', 'docker-is')
)]

[cmdletbinding()]
param(
    [parameter(ValueFromRemainingArguments = $true)]
    [string[]]$Arguments
)

$q = $Arguments -split ' '

$env:docker_host = "tcp://$($q[0]):2375"
$search =  "$($q[1])"

    if (!$search) {
    write-error "Please enter search criteria for docker inspect`nExample Usage: % docker-inspect (host) (Name or ContainerId filter)"
    }
    else {
    $dis = docker inspect $search
    $dis | out-file -filepath $PSscriptRoot\$search.json -Force
    New-PoshBotFileUpload -Path $PSscriptRoot\$search.json -Title "$search.json"
    New-PoshBotCardResponse -Type Normal -Title "Example Usage" -Text "% docker-inspect (host) (Name or ContainerId filter)"
    $fields = @{
        Host = $q[0]
        Search = $q[1]
    }
    New-PoshBotCardResponse -Type Normal -Fields $fields
    }
}

Export-ModuleMember -Function 'Docker-Inspect'