Function Test-PortAvailable
{
param(
[validaterange(1,65535)]
[int]$Port
)
$sockt=New-Object -ArgumentList 'InterNetwork','Stream','TCP'
$ip = (Get-NetIPConfiguration).IPv4Address |
Select -First 1 -ExpandProperty IPAddress
$ipAddress = []::Parse($ip)
Try
{
$ipEndpoint = New-Object $ipAddress,$port
$($ipEndpoint)
return $true
}
Catch [exception]
{
return $false
}
Finally
{
$()
}
}