Jun 24, 2026, 1:06 PM
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
$Headers = @{
|
||||
"Accept" = "application/json"
|
||||
"Content-Type" = "application/json"
|
||||
}
|
||||
|
||||
$Prefix = "CH"
|
||||
$Limit = 100
|
||||
$Offset = 0
|
||||
$AllRows = @()
|
||||
$Total = $null
|
||||
|
||||
do {
|
||||
$Body = @{
|
||||
query = @"
|
||||
{
|
||||
GlideRecord_Query {
|
||||
cmdb_ci_server(
|
||||
pagination: {limit: $Limit, offset: $Offset},
|
||||
queryConditions: "nameSTARTSWITH$Prefix"
|
||||
) {
|
||||
_rowCount
|
||||
_results {
|
||||
name {
|
||||
value
|
||||
displayValue
|
||||
}
|
||||
sys_id {
|
||||
value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"@
|
||||
} | ConvertTo-Json -Depth 20
|
||||
|
||||
$response = Invoke-RestMethod `
|
||||
-Method Post `
|
||||
-Uri "https://dnbgatewayprod.service-now.com/api/now/graphql" `
|
||||
-Headers $Headers `
|
||||
-Body $Body
|
||||
|
||||
$batch = $response.data.GlideRecord_Query.cmdb_ci_server._results
|
||||
|
||||
if ($null -eq $Total) {
|
||||
$Total = $response.data.GlideRecord_Query.cmdb_ci_server._rowCount
|
||||
}
|
||||
|
||||
$AllRows += $batch
|
||||
$Offset += $Limit
|
||||
|
||||
Write-Host "Pobrano: $($AllRows.Count) / $Total"
|
||||
|
||||
} while ($batch.Count -gt 0 -and $AllRows.Count -lt $Total)
|
||||
|
||||
$Table = $AllRows |
|
||||
Select-Object `
|
||||
@{Name='Name'; Expression={$_.name.value}},
|
||||
@{Name='DisplayName'; Expression={$_.name.displayValue}},
|
||||
@{Name='SysId'; Expression={$_.sys_id.value}}
|
||||
|
||||
$Table | Format-Table -AutoSize
|
||||
Reference in New Issue
Block a user