new-scsmincident get id of this new incident?

Jan 17, 2015 at 1:57 PM
Hi Together,

currently i'm working on a Script with which i can import Tickets from another Ticketsystem via CSV.

I managed to do that because its quite easy with the new-scsmincident cmdlet.

But now i should have the ID of the newly created incident to add the assigned to user to the incident.

Acutaly i try it with:

$id = (Get-SCSMIncident -Title "$ticketidmx + $title").id

Because i save the ticket-id of the other Ticketsystem and the title of the incident in the new incident in SCSM.

But i think thatss not "save" enough.

So is there any possibilty to get the ID of the newly created incident direclty after creating it with new-scsmincident?

thank you

Feb 6, 2015 at 6:29 AM
Edited Feb 6, 2015 at 6:31 AM

i have a powershell script where this feature has been used :)

To create the new incident use this line (you can remove fields you dont need)

$incidentid = (New-SCSMIncident -title $global:title -Description $global:description -Impact $global:impact -Urgency $global:urgency -Classification $global:classification -Status $global:Status -SupportGroup $global:TierQueue -Source "Phone" -Passthru).Object

Your ticket id is inside $incidentid
Now you can use this to get informations from the new incident:
$i = Get-SCSMObject (Get-SCSMClass System.WorkItem.Incident$) -Filter "Id -eq $ID"

If you need more informations tell me