Skip to content

Commit 0f81be8

Browse files
committed
fix #136
1 parent 21390dc commit 0f81be8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

ServiceNow/Private/Invoke-ServiceNowRestMethod.ps1

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff 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 ) {

0 commit comments

Comments
 (0)