Need help in PowerShell code to update Incident form using SMLets

jansi rani krishnan 601 Reputation points
2021-06-21T15:13:37.163+00:00

Hi Experts,

  1. I would like to update the fields in the Resolution Tab in the Incident form. I tried the below set of commands using PowerShell.

$IRId="IR5008"
$incidentClass = Get-SCSMClass -Name System.workitem.Incident$
$IO = Get-SCSMObject -Class $incidentClass -filter "ID -eq $IRId"

$ResolutionToChange=@{
"Status" = "Resolved";
"ResolutionDescription" = "Ticket Resolved by Analyst";
"ResolutionCategory" = "Resolved by Work Around";
"ResolvedDate" = (Get-Date).ToUniversalTime();
"TargetResolutionTime" = (Get-Date).ToUniversalTime();
}
Set-SCSMObject -SMObject $IO -PropertyHashtable $ResolutionToChange

The field "Resolved by User" is not getting updated. Please share any ideas on how to update this field. The remaining fields are getting updated as below.

107618-image.png

  1. Please share me any code sample on how to update the AssignedTo field in Incident form using SMLets.

Regards,
Jansi

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Andreas Baumgarten 123.7K Reputation points MVP Volunteer Moderator
    2021-06-22T19:43:19.87+00:00

    Hi @jansi rani krishnan ,

    the error is because the variable $resolvedByUserObj is empty ( -Target $resolvedByUserObj in LIne 32 in my script in Github).
    And this is because the user with the username Jansi Krishnan_adm is not found (Line 18 in my script in Github).
    Is there a space in the username? Or it's a typo?
    Please check the user Jansi Krishan_adm (with or without the space, depending of what is the right spelling) is available in the SCSM Console -> Configuration Items -> Users .

    ----------

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

    Regards
    Andreas Baumgarten


1 additional answer

Sort by: Most helpful
  1. Andreas Baumgarten 123.7K Reputation points MVP Volunteer Moderator
    2021-06-21T16:29:14.617+00:00

    Hi @jansi rani krishnan ,

    please give this a try:
    https://github.com/abaumgarten42/SCSM_Useful_PSscripts/blob/main/Resolve-Incident.ps1

    ----------

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

    Regards
    Andreas Baumgarten


Your answer

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