TCP-Teste.psm1

<#
.SYNOPSIS
A function to handle test tcp connections
library found here on CodePlex: http://sshnet.codeplex.com/
 
Copyright (c) 2016.
All rights reserved.
Author: Marcos Flavio Alves da Silva
 
.DESCRIPTION
See:
Get-Help test-conexao
 
#>

function test-conexao {
    param(
    [Parameter(Mandatory=$true)][int]$porta,
    [Parameter(Mandatory=$true)][string]$ip
    )
    $con= New-Object System.Net.Sockets.TcpClient
    try{
        $con.Connect($ip,$porta)
        return $con.Connected
    }catch{
        return $false
    }

}

######## END OF FUNCTIONS ########

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

Export-ModuleMember test-conexao