Share via

Need some help on powershell command

jansi rani krishnan 601 Reputation points
2021-04-26T18:58:17.453+00:00

Hi Team,

I have a requirement to retrieve incident information and convert to JSON format to be sent in REST webservice call.

Example:

I can fetch the values in an incident using the below command.

$IC=get-SCSMclass -name system.workitem.incident$
$IO=get-SCSMobject -class $IC | select-object *

I have no idea on how to parse this information (each field) and convert to JSON format in order to make a web-service call using the command "Invoke-RESTMethod"

Can anyone please help me out on how to proceed?

It would really be a great help!!!

Thanking you in advance.

Regards,
-Jansi

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

Answer accepted by question author

Andreas Baumgarten 132.1K Reputation points MVP Volunteer Moderator
2021-04-26T19:52:12.79+00:00

Hi @jansi rani krishnan ,

maybe this helps to start:

$IRid = "IR2031"  
$IC = Get-SCSMclass -name System.Workitem.Incident$  
$IO =  Get-SCSMobject -class $IC -filter "ID -eq $IRid" | Select-Object *  
$IO | ConvertTo-Json  

----------

(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

Regards
Andreas Baumgarten

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.