File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -147,9 +147,14 @@ function Invoke-ServiceNowRestMethod {
147147 $oldProgressPreference = $ProgressPreference
148148 $ProgressPreference = ' SilentlyContinue'
149149
150- $response = Invoke-WebRequest @params
151-
152- Write-Debug ($response | ConvertTo-Json )
150+ try {
151+ $response = Invoke-WebRequest @params
152+ Write-Debug $response
153+ }
154+ catch {
155+ $ProgressPreference = $oldProgressPreference
156+ throw $_
157+ }
153158
154159 # TODO: this could use some work
155160 # checking for content is good, but at times we'll get content that's not valid
@@ -200,7 +205,13 @@ function Invoke-ServiceNowRestMethod {
200205 }
201206
202207 Write-Verbose (' getting {0}-{1} of {2}' -f ($params.body.sysparm_offset + 1 ), $end , $totalRecordCount )
203- $response = Invoke-WebRequest @params - Verbose:$false
208+ try {
209+ $response = Invoke-WebRequest @params - Verbose:$false
210+ }
211+ catch {
212+ $ProgressPreference = $oldProgressPreference
213+ throw $_
214+ }
204215
205216 $content = $response.content | ConvertFrom-Json
206217 if ( $content.PSobject.Properties.Name -contains " result" ) {
You can’t perform that action at this time.
0 commit comments