Skip to content

Instantly share code, notes, and snippets.

@kpatnayakuni
Created August 30, 2019 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kpatnayakuni/1edc00b2597faae0fa45bf8ef9d31373 to your computer and use it in GitHub Desktop.
Save kpatnayakuni/1edc00b2597faae0fa45bf8ef9d31373 to your computer and use it in GitHub Desktop.
PS C:\Users\kiran> Try { Test-Connection "localhost" -Count 1 } Catch { Write-Host "Connection Error" } Finally { Write-Host "`nTest Complete" }
Source Destination IPV4Address IPV6Address Bytes Time(ms)
------ ----------- ----------- ----------- ----- --------
Workstation localhost 127.0.0.1 ::1 32 0
Test Complete
PS C:\Users\kiran> Try { Test-Connection "localhost1" -Count 1 } Catch { Write-Host "Connection Error" } Finally { Write-Host "`nTest Complete" }
Test-Connection : Testing connection to computer 'localhost1' failed: No such host is known
At line:1 char:7
+ Try { Test-Connection "localhost1" -Count 1 } Catch { Write-Host "Con ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (localhost1:String) [Test-Connection], PingException
+ FullyQualifiedErrorId : TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand
Test Complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment