Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Sam-Martin/d76e05d0b3f37c429afb to your computer and use it in GitHub Desktop.
Save Sam-Martin/d76e05d0b3f37c429afb to your computer and use it in GitHub Desktop.

Replace yourdomain with your service now URL. User must have the rest_service role.

if(!$script:ServiceNowCreds){
$script:ServiceNowCreds = Get-Credential
}
$uri = 'https://yourdomain.service-now.com/api/now/table/incident?sysparm_limit=10'
$Body = @{
'sysparm_query' = 'ORDERBYDESCopened_at'
}
$result = Invoke-RestMethod -Uri $uri -Credential $script:ServiceNowCreds -Body $Body -ContentType "application/json"
$result.result | select opened_at, number, short_description
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment