Passing user object to script in workflow

Hi

I'm trying to get a workflow to run which will update extensionAttribute7 of a user object when it's been added to a group, based on the users job title.
e.g. Joe Bloggs gets added to the group, his title is IT, EA7 needs to be set to "03452"
Jane Bloggs gets added to the group, her title is Director, EA7 needs to be set to "56643".

My workflow identifies the correct user object, and if I specify the value of EA7 in the target properties as a text value, works fine, but because of the number of options for the value of EA7, I've had to create a script with a lookup table and I cannot figure out how to pass the users job title, or DN to that script.
I followed this KB to create the workflow and identify the user to be updated and my script will execute when it's specified in the Target properties.

I also read through this forum post, which helped me find the ActivityTarget method. I'm sure this must be what I need, but I can't get it to work.

The best I can do is to use the lines

$user = $workflow.ActivityTarget
$user | Select * | Out-File E:\MC\Workflow\user.txtCode

Which then gives me this output

MemberType : Method
OverloadDefinitions : {System.Object ActivityTarget(string ActivityID)}
TypeNameOfValue : System.Management.Automation.PSMethod
Value : System.Object ActivityTarget(string ActivityID)
Name : ActivityTarget
IsInstance : TrueCode

But no matter what I change with the "$user = $workflow.ActivityTarget" line, I cannot get it to provide any information on the user object.
I've tried

$user = $workflow.ActivityTarget("Change object properties")
$user = $workflow.ActivityTarget("Add member to group")
$user = $workflow.ActivityTarget("Added member")

Which all produce an empty users.txt document, so I added the get method.

$user = $workflow.ActivityTarget("Change object properties").get("distinguishedName")
$user = $workflow.ActivityTarget("Add member to group").get("distinguishedName")
$user = $workflow.ActivityTarget("Added member").get("distinguishedName")

All of which result in "You cannot call a method on a null-valued expression" errors in the debug log.

Can someone please help point me in the right direction with this?

Many thanks

Matt

  • Which powershell module do I require for this

  • There are no special Powershell modules required for Policy Script code as the $Request, $Workflow and $Context objects are native to the Powershell runtime environment instantiated by the AR Admin service.

    If you need to use the "QAD..." cmdlets to execute scripts on your on workstation (as opposed to the AR server), you would need to install the ActiveRolesManagementShell.  The easiest way to get all the needed components is to perform a "Management Tools" install from the AR install package.

    To use the native AD cmdlets (Example:  Get-ADUser), you would need to ensure that the ActiveDirectory Powershell module is installed on your AR server.