File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -167,8 +167,16 @@ function Invoke-ServiceNowRestMethod {
167167 $records = @ ($content )
168168 }
169169
170- $totalRecordCount = [int ]$response.Headers .' X-Total-Count'
171- Write-Verbose " Total number of records for this query: $totalRecordCount "
170+ $totalRecordCount = 0
171+ if ( $response.Headers .' X-Total-Count' ) {
172+ if ($PSVersionTable.PSVersion.Major -lt 6 ) {
173+ $totalRecordCount = [int ]$response.Headers .' X-Total-Count'
174+ }
175+ else {
176+ $totalRecordCount = [int ]($response.Headers .' X-Total-Count' [0 ])
177+ }
178+ Write-Verbose " Total number of records for this query: $totalRecordCount "
179+ }
172180
173181 # if option to get all records was provided, loop and get them all
174182 if ( $PSCmdlet.PagingParameters.IncludeTotalCount.IsPresent ) {
You can’t perform that action at this time.
0 commit comments