Remotely Testing Firewall Access

Assume you get a request to test if a remote computer has firewall access to a remote server on a remote port.  You either are too lazy to walk over to said remote computer, it is just not practical, or you don’t want to interrupt the user from their daily work.

The following powershell code will accomplish that!  This assumes you have rights to launch remote powershell sessions on that remote computer:


$strComputer = “ComputerYouWantToTestFrom”           #Computer you want to test

$strRemoteHost = “ServerYouWantToTestAccessTo”               #Remote Host you want to test access to

$pssession = New-PSSession -ComputerName $strComputer -Name MK –EnableNetworkAccess

$PSsession | Enter-PSSession

(New-Object System.Net.Sockets.TCPClient).connect("${strRemoteHost}",80) | ForEach{$_.dispose()}

exit

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s