Skip to content

Instantly share code, notes, and snippets.

Revisions

  1. Sam-Martin created this gist May 3, 2015.
    1 change: 1 addition & 0 deletions ServiceNow API Example in PowerShell.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    Replace `yourdomain` with your service now URL. User must have the `rest_service` role.
    11 changes: 11 additions & 0 deletions servicenow-rest-example.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    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