File tree 1 file changed +15
-4
lines changed
1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -147,9 +147,14 @@ function Invoke-ServiceNowRestMethod {
147
147
$oldProgressPreference = $ProgressPreference
148
148
$ProgressPreference = ' SilentlyContinue'
149
149
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
+ }
153
158
154
159
# TODO: this could use some work
155
160
# checking for content is good, but at times we'll get content that's not valid
@@ -200,7 +205,13 @@ function Invoke-ServiceNowRestMethod {
200
205
}
201
206
202
207
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
+ }
204
215
205
216
$content = $response.content | ConvertFrom-Json
206
217
if ( $content.PSobject.Properties.Name -contains " result" ) {
You can’t perform that action at this time.
0 commit comments