[4:40 PM]ndl@FWTS012:Powershell_Test $ $error[0].Exception.Message
Connecting to remote server TESTVM160418 failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the service on the des
tination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination i
s the WinRM service, run the following command on the destination to analyze and configure the WinRM service: “winrm quickconfig”. For more information, see the about_Remote_Troubleshootin
g Help topic.
Basically, you’re telling PS to completely ignore all errors that crop up. This effectively negates the try block for the command you apply it to and renders it useless; it can’t catch a suppressed error.
By default, some errors in PS are terminating, and others are not. To consistently ensure that any errors trigger your catch block, you must instead use -ErrorAction Stop