QTelnet.ps1 (1183B)
1 [CmdletBinding()] 2 param( 3 [Parameter(Mandatory=$true, 4 ValueFromPipeline=$true, 5 ValueFromPipelineByPropertyName=$true)] 6 [Alias ('HostName','cn','Host','Computer')] 7 [String]$ComputerName='localhost', 8 [Parameter(Mandatory=$true, 9 ValueFromPipeline=$true, 10 ValueFromPipelineByPropertyName=$true)] 11 [int]$Port, 12 [int] $Timeout = 10000 13 ) 14 foreach($Computer in $ComputerName) { 15 Try { 16 $tcp = New-Object System.Net.Sockets.TcpClient 17 $connection = $tcp.BeginConnect($Computer, $Port, $null, $null) 18 $connection.AsyncWaitHandle.WaitOne($timeout,$false) | Out-Null 19 if($tcp.Connected -eq $true) { 20 Write-Host "Epic Gamer Elite Hacking Squad successfully connected to Host: `"$Computer`" on Port: `"$Port`"" -ForegroundColor Green 21 } 22 else { 23 Write-Host "Epic Gamer Elite Hacking Squad could not connect to Host: `"$Computer`" on Port: `"$Port`"" -ForegroundColor Red 24 } 25 } 26 27 Catch { 28 Write-Host "Epic Gamer Elite Hacking Squad had an EPIC error!" -ForegroundColor Red 29 } 30 31 }