Home Powershell Activity

Mapping Inputs from Advance Request Offering Forms Into Powershell Activity

Russell_KlvacekRussell_Klvacek Customer IT Monkey ✭
What would be the best way to do this? I'd very much like to trigger an Azure automation runbook dynamically based on the form input, but, unlike a Runbook Activity, Powershell Activity doesn't seem to provide a way to directly map parameters over.

Any insight?

Answers

  • Jeff_LangJeff_Lang Customer Ninja IT Monkey ✭✭✭✭
    Within the powershell activity, you can load the parent request, then get all the user inputs and set them to variables within the powershell activity, you can then use them however you need to once set
  • Mark_AshwoodMark_Ashwood Customer IT Monkey ✭

    I too have the same issue, I can load the values from the parent request to the PowerShell activity but in the service offering the prompts need to be mapped somewhere in the parent request to be accessible.

    e.g. in a Orchestrator map prompt 1 to text 1 in the RunBook template

    Where there are 5 - 10 questions we can't just use a unused field like notes as this can only have one prompt mapped.

    Any help would be appreciated.

  • Jeff_LangJeff_Lang Customer Ninja IT Monkey ✭✭✭✭
    assuming you are passing through the Service Request GUID to the variable $SRGUID, the following should work i think
    #get Service Request Object<br>$SR = Get-SCSMClassInstance -ID $SRGUID<br><br>#get base workitem <br>$WIClass = Get-SCSMClass -Name - System.workitem<br>$WI = get-SCSMObject -Class $WIClass -Filter "Id -eq $SR.Id"<br><br>$userInput = $WI.Userinput<br><br>

    then it's just a matter of looping through the user input
  • Mark_AshwoodMark_Ashwood Customer IT Monkey ✭
    Jeff, thanks for the help, but where do you map the prompts too if they are not mapped the error "The output of every prompt should be mapped to a property, assigned to a relationship, or consumed by a subsequent prompt." on the creation of the request offering?
  • Jeremy_CastleberryJeremy_Castleberry Customer IT Monkey ✭

    not sure if this is exactly what you mean but I will try to help    I have say 10 questions.  3 might be queries for users - and they all end up as "related users" so its hard to know which one is mapping to which user question.  The other 7 questions are strings or dates and line up nice and pretty as variables.

     One option is to look at UserInput as Jeff  Suggested it - parse the XML.   

    So what I did - so that I didn't have to break out the XML from the Userinput was:

    1. Configure the outputs like normal,  querys = related and text = mapped.

    2. I use the multiple mapping to add the output of the three user questions to a variable - just like the text ones are mapped.

    3. Then - In my powershell I can query all the variables of the SR, including the "multimapped" ones and get strings for each answer.

    4.  Now to verify the string Is which specific user (like we have two John Smiths) - I take the "string" John Smith and I then get the related objects to he SR that match John Smith.  Now only one was chosen (hopefully) and so now I have the Object, not just a string. 

    Maybe this will help you with some ideas.

Sign In or Register to comment.