From 135e698731f29c4418d7c71d2f454f928ac5325c Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 31 Mar 2019 20:06:05 -0400 Subject: [PATCH] Specify ErrorAction:Stop for connection errors --- ZertoApiWrapper/Public/Connect-ZertoServer.ps1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 index 232e420..3ce5e49 100644 --- a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 +++ b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 @@ -20,8 +20,7 @@ function Connect-ZertoServer { Mandatory = $true, HelpMessage = "Valid credentials to connect to the Zerto Management Server" )] - [System.Management.Automation.PSCredential] - $credential, + [System.Management.Automation.PSCredential]$credential, [switch]$returnHeaders ) @@ -39,7 +38,7 @@ function Connect-ZertoServer { process { # Send authorization request to the function and send back the results including headers - $results = Invoke-ZertoRestRequest -uri $uri -credential $credential -returnHeaders -body $body -method POST + $results = Invoke-ZertoRestRequest -uri $uri -credential $credential -returnHeaders -body $body -method POST -ErrorAction Stop } end {