Hi Everyone!
I wrote script which will add new request, SD said
Action Executed is :
test2
Message:
successfully executed,
but nothing changes.
Command in custom scripts cmd /c start /wait powershell.exe -file C:\ManageEngine\ServiceDesk\integration\custom_scripts\test.ps1 $COMPLETE_JSON_FILE.
PS version 3.0, also i manage execution policy, now it unrestricted. Maybe someone can tell what wrong?
p.s. Run this script on server manually, it create request, but without params (line 11-13).
Script text:
- param (
- [string]$json = "none"
- )
- $jsondata = Get-Content $json
- write-host $jsondata
- $obj = ConvertFrom-Json $jsondata
- #Ticket Information
- $ticket = $obj.request.WORKORDERID
- $requester = $obj.request.REQUESTER
- $site = $obj.request
- $inputData = @"
- <Operation>
- <Details>
- <requester>$requester</requester>
- <category>Category1</category>
- <subcategory>Subcategory1</subcategory>
- <item>Item1</item>
- <subject>Test</subject>
- <site>$site</site>
- <rating>15.0</rating> #my additional field
- <description>test message id $ticket. </description>
- <requesttemplate>Default Request</requesttemplate>
- <group>Group 1</group>
- </Details>
- </Operation>
- "@
- $postParams = @{OPERATION_NAME = 'ADD_REQUEST' ;TECHNICIAN_KEY = 'key' ;INPUT_DATA = $inputData}
- $URI = "http://localhost:8080/sdpapi/request"
- Invoke-WebRequest -Uri $URI -Method Post -Body $postParams