In my quest to port the Kung Fu of Mr. Skoudis in to powershell I came up with this command:
PS C:\> echo (1+1) (2+2)
If we replace the (1+1) with (1/0) then nothing is displayed (other than the error). . If we discard the error with 2>Out-Null then there is no output.
PS C:\> echo (1/0) (2+2) 2>Out-Null(No Output)
We can use this to our advantage. If our connection fails, an error is raised and we don't output the "$_ is open" portion. If the connection works then the "$_ is open" is displayed.
Unfortunately, there is no easy way to change the connection timeout so this process is slow. We can do it with asynchronous calls, but that is a lot of work and is no longer a one liner. I'll put that in a future version.