Specify ErrorAction:Stop for connection errors
This commit is contained in:
@@ -20,8 +20,7 @@ function Connect-ZertoServer {
|
|||||||
Mandatory = $true,
|
Mandatory = $true,
|
||||||
HelpMessage = "Valid credentials to connect to the Zerto Management Server"
|
HelpMessage = "Valid credentials to connect to the Zerto Management Server"
|
||||||
)]
|
)]
|
||||||
[System.Management.Automation.PSCredential]
|
[System.Management.Automation.PSCredential]$credential,
|
||||||
$credential,
|
|
||||||
[switch]$returnHeaders
|
[switch]$returnHeaders
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -39,7 +38,7 @@ function Connect-ZertoServer {
|
|||||||
|
|
||||||
process {
|
process {
|
||||||
# Send authorization request to the function and send back the results including headers
|
# 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 {
|
end {
|
||||||
|
|||||||
Reference in New Issue
Block a user