Public/Invoke-TestPort.ps1

function Invoke-TestPort {
    <#
    .SYNOPSIS
        Invokes a network connection test
    .PARAMETER ComputerName
        Target computer name
    .PARAMETER TestPort
        Target port to test connection to
    .EXAMPLE
        !port SSCN115
    #>

    [PoshBot.BotCommand(
        CommandName = 'port',
        Aliases = ('testport', 'netconnection', 'net')
    )]
    [cmdletbinding()]
    param(
        [parameter(Mandatory)]
        [string]$ComputerName,
        [parameter(Mandatory)]
        [int]$TestPort
    )

    try {
        $result = Test-NetConnection -ComputerName $ComputerName -Port $TestPort
        New-PoshBotCardResponse -Text ($result | Out-String)
    }
    catch {
        Write-Output "$($_.Exception.Message)"
        Write-Output "$($_.error.message)"
    }
}