Use Powershell to update a Ticket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2018 07:43 AM
Hi,
I am working on a PowerShell based script to update a ticket in ServiceNow. The process I would be following is: -
Retrieve a Service Now Incident
Download it in XML/JSON format
Update the fields such as Work Log/Close or Reopen a Ticket
and then Use the PowerShell to post the Update to Service Now.
I am able to get a ticket but posting an update to ServiceNow seems to be whol;e different ballgame. The code I have so far is as below: -
if(!$ServiceNowCreds){
$ServiceNowCreds = Get-Credential
}
$uri = 'https://dev22777.service-now.com/api/now/table/{table_name}/{sys_id}
#sys_id=df01d2434f41130095d22ed18110c704'
$Body = "<request><entry>
<work_notes>Issue is resolved</work_notes>
</entry></request>"
$result = Invoke-RestMethod -Method Patch -Uri $uri -Credential $ServiceNowCreds -Headers $headers -Body $Body -ContentType "application/json"
Request your help/assistance in this regard.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2018 10:56 AM
I don't see {table_name} variable value anywhere in code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2018 03:22 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2018 03:28 PM
If you are trying to update incident than table name needs to be incident.
like https://dev22777.service-now.com/api/now/table/incident/{sys_id}