0

Is there a way to check reachability of an IP address when firewall is enabled?

I am pinging an IP that has firewall enabled, therefore ping, Test-Connection and TCP Client, all three are not working.

Ping request is failing and Test-Connection is giving error:

Test-Connection : Testing connection to computer 'ComputerName' failed: Error due to lack of resources At line:1 char:1

TCP client is also showing error message:

New-Object : Exception calling ".ctor" with "2" argument(s): "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 192.168.1.193:443"

henrycarteruk
  • 12,708
  • 2
  • 36
  • 40
Areeb Younus
  • 13
  • 1
  • 2
  • 2
    What, exactly, are you [trying to achieve](https://meta.stackexchange.com/q/66377)? The main point of a firewall is to restrict network access, so what's behind one is hidden. – vonPryz Sep 04 '18 at 07:34

1 Answers1

1

There are other things that can cause the error. This is a common error that is easily looked up on the web even by using the search field on this site. So, your post could be a duplicate of this post and answer...

Powershell - Test-Connection failed due to lack of resources

This is not a PS code issue, but as you note a firewall or server config issue simply blocking ping (which is what Test-Connection, Test-NetConnection cmdlets do) or other communication problem. So, actually this is a better question for the SuperUser side vs stackoverflow.

So, what it sounds like you are asking for here, they way you are asking it, is how to skirt your organizations firewall / host config polices (at your edge server or the target host) for what ever reason and you should really be talking to them as to why they are not allowing ping to specific targets.

All that being said. You can use other cmdlets to test if a host or website is reachable.

Here is a list that does not PSRemoting or admin credentials, if you are inside the network...

Specially starting with the …

Get-WmiObject -Class Win32_OperatingSystem -ComputerName '192.168.1.193'

As well as ...

Test-WSMan -ComputerName '192.168.1.193'

... Any other PS cmdlets require you be admin on the target.

If this is a web server, you'd look to the web cmdlets …

Invoke-WebRequest -Uri 'http:\\192.168.1.193'

Again, you should be talking to the policy makers, as they could just as well block all this as well. Lastly, IMHO, if this is not your role, you may encounter other negative items if you are called to the carpet for doing this. Just saying...

henrycarteruk
  • 12,708
  • 2
  • 36
  • 40
postanote
  • 15,138
  • 2
  • 14
  • 25