Return multiple properties with a single Query

How to return multiple properties to one Action with one Query

Version 2020R1

From SR version 2020R1 it is possible to return multiple properties in scripted Queries. To return those properties, a Hashtable must be used in the Query script.

Example of a Hashtable (PSCustomObject can also be used):

$usr = Get-ADUser -Identity Jeff.ScriptWalker -Properties @('Surname','GivenName','PostalCode','City','StreetAddress')
[hashtable]$result = @{
  FirstName = $usr.GivenName
   LastName = $usr.Surname
   Street = $usr.StreetAddress
   PLZ = $usr.PostalCode
   City = $usr.City
}

$null = $SRXEnv.ResultList.Add($result)
$null = $SRXEnv.ResultList2.Add('Jeff.ScriptWalker')

In the script of the Action, a parameter of type Hashtable is declared, to which the Query is assigned.

Example:

 param( 
  [Hashtable] $UserProperties,   
...
  • Once the Action is started, the Query starts and returns the results as before.
  • After selecting a Query result, the Hashtable from the Query script result with the properties is assigned to the parameter in the Action script.
  • Within the script, the individual properties can now be used.
  • It is now possible to pass several properties bundled per Query to an Action
    instead of creating a Query for each property.

Version 2020R2

Since version 2020R2, the properties of the selected object are displayed in the following parameters. For this purpose, the parameter name must match the property name, e.g. $FirstName.

This functionality can only be used with a Hashtable parameter

For this functionality, the parameter must be declared in the script with the following attribute:

 HelpMessage="ASRDisplay(Splatting)" 

Example:

 param(
   [Parameter(HelpMessage="ASRDisplay(Splatting)")]
               [Hashtable] $UserProperties,
...