diff --git a/IsilonPlatform/IsilonPlatform.psm1 b/IsilonPlatform/IsilonPlatform.psm1 index 23b71c8..3d0383d 100644 --- a/IsilonPlatform/IsilonPlatform.psm1 +++ b/IsilonPlatform/IsilonPlatform.psm1 @@ -449,12 +449,17 @@ function Send-isiAPI{ $result = $_.Exception.Response.GetResponseStream() $reader = New-Object System.IO.StreamReader($result) $responseBody = $reader.ReadToEnd() | ConvertFrom-Json - $responeMessage = $responseBody.errors.message | Out-String - Write-Error $responeMessage + if ($responseBody.PSObject.Properties.name -contains "errors") { + $errorResponse = $_.Exception.Message + " " + $responseBody.errors.message + } elseif ($responseBody.PSObject.Properties.name -contains "message") { + $errorResponse = $_.Exception.Message + " " + $responseBody.message + } else { + $errorResponse = $_.Exception.Message + } + Write-Error $errorResponse } else { Write-Error $_.Exception } - } $isi_session.timeout = (Get-Date).AddSeconds($isi_session.timeout_inactive) $ISIObject