Bulk Machine Remote Telnet PowerShell Script

How to do remote Telnet from multiple source machines & ports.

$Servers = "Computer1",

"Computer2",

"Computer3",

"Computer4",

"Computer5"

 $Ports   =  "443"    

$Destination = "192.168.1.5"

$Results = @()

$Results = Invoke-Command $Servers {param($Destination,$Ports)

                $Object = New-Object PSCustomObject

                $Object | Add-Member -MemberType NoteProperty -Name "ServerName" -Value $env:COMPUTERNAME

                $Object | Add-Member -MemberType NoteProperty -Name "Destination" -Value $Destination

                    Foreach ($P in $Ports){

                        $PortCheck = (Test-NetConnection -Port $p -ComputerName $Destination ).TcpTestSucceeded

                        If($PortCheck -notmatch "True|False"){$PortCheck = "ERROR"}

                        $Object | Add-Member Noteproperty "$("Port " + "$p")" -Value "$($PortCheck)"

                    }

                $Object

           } -ArgumentList $Destination,$Ports | select * -ExcludeProperty runspaceid, pscomputername -Verbose

            $Results | Format-Table -AutoSize | Out-file "C:\temp\portstatus.csv" -Append


============================

# Add the source servers separated with comma " , "

# Make sure the last source server doesn’t end with a comma

To check multiple port status add separated with comma " " , " "

$Ports   =  "445",

                  "139"

5 comments:

  1. China Longwell is a professional China EPS Machine, EPS moulding machine Supplier. We offer kinds of EPS machines, EPS moulding machine, EPS molds, 3D panel machines, sandwich panel machines, assistant facilities and all kinds of EPS machine spare parts China Polystyrene machine manufacturer

    ReplyDelete
  2. Superbly written article, if only all bloggers offered the same content as you, the internet would be a far better place.. Buy Goldshell Kd5

    ReplyDelete
  3. China JIALITE is one of the leading Automatic pre-coating laminating machine, Water Base Oil Coating Machine, automatic coating machine Manufacturers,Factory and Suppliers, Our product quality has passed international certification, and the price is affordable, welcome to call and order our products wholesale. Automatic Paper Sheet Laminating Machine

    ReplyDelete
  4. I finally found great post here.I will get back here. I just added your blog to my bookmark sites. thanks.Quality posts is the crucial to invite the visitors to visit the web page, that's what this web page is providing. NVIDIA CMP 170HX Pro Mining 164MH/s 205W

    ReplyDelete

Featured Post

HPE MSA 2040 configuration step by step

HPE MSA 2040 configuration Default IP range for HP SAN storage MSA 2040 is 10.0.0.1/2 You need to connect your laptop and storage with...