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." 

  • 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

  • To clarify this:

    Anything (any activity) you place in the workspace of the Search (that is the gray box immediately below the Search Activity) is executed for each returned object.

  • Thanks   - that along with a couple of other bits has moved the issue along. 

    The problem i now have is my workflow search filter needs to look for users where the edsvaDeprovisionStatus is not 1 (i.e not deprovisioned). I have compared a deprovisioned user and one a user that i want to deprovision and the difference is that the deprovisoned user has their edsvaDeprovisionStatus as 1 however in my search if i set it to either "does not equal 1" or "is empty" my powershell script will not detect the users and trigger the workflow. 

    Any suggestions? 

  • What, if any, other criteria are you using in your Search?

    Would you be able to post a screen cap of the Search Activity configuration?

  • One thing I do sometimes to make things easier to manage is I will create a Managed Unit populated with the search criteria that I might otherwise place into a Search Activity.  That way I can always see what objects are "in scope" if you will.

    Then, in my Scheduled Workflow, instead of using a Search Activity, the first thing I do (usually in a script) is enumerate the contents of the MU.  

    Then my script does what it needs to do with the returned objects.

    Granted, the disadvantage to this approach is that everything has to be in one script OR each script in the scheduled workflow needs to re-enumerate the MU.

    But, it does get you around the problem of not knowing what a Search Activity is (or isn't) returning.

    Food for thought.