Workflow SavedObjectProperties for multiple results (users)

Hi, 

I have a scheduled workflow that filters users based on a VA and then searches for users with this VA in a specific OU and then runs some PowerShell scripts for various things. 

I've used both of the commands below but neither seems to work, so i guess my question is how do I refer to "workflow Saved object properties" for multiple users without needing a For Each?

Script 1: $useremail = $workflow.SavedObjectProperties("searchforobjects").get("mail")

Error: At line: 11 char:5. Exception calling "SavedObjectProperties" with "1" argument(s): "The given key was not present in the dictionary."

Script 2: $useremail = $workflow.FoundObject("searchforobjects").get("mail")

Error: At line: 8 char:5. Exception calling "Get" with "1" argument(s): "Object reference not set to an instance of an object." 

Parents
  • The Search itself sets up the For each for you.

    Anything you place in the workspace of the Search is executed for each returned object.

    Your "Script 2" example is the way I would approach this.

    The key is making sure that you are referencing the name of your Search Activity correctly:

    So if my Search is Called "FindManagers"

    $useremail = $workflow.FoundObject("FindManagers").get("mail")

    I'm not sure if you actually can ask for the "mail" property directly this way or if you have to do it like this:

    $user = $workflow.FoundObject("FindManagers").get("distinguishedname")

    $usermail = Get-QADUser -Identity $User -includedproperties mail | select -ExpandProperty mail

Reply
  • The Search itself sets up the For each for you.

    Anything you place in the workspace of the Search is executed for each returned object.

    Your "Script 2" example is the way I would approach this.

    The key is making sure that you are referencing the name of your Search Activity correctly:

    So if my Search is Called "FindManagers"

    $useremail = $workflow.FoundObject("FindManagers").get("mail")

    I'm not sure if you actually can ask for the "mail" property directly this way or if you have to do it like this:

    $user = $workflow.FoundObject("FindManagers").get("distinguishedname")

    $usermail = Get-QADUser -Identity $User -includedproperties mail | select -ExpandProperty mail

Children