When using a PowerShell script when mapping in Quick Connect or the Active Roles Synchronization Service, using either $dstObj or $commonParameters.CommonVars.TargetObject return a NULL or empty object.
This could result in a script error such as:
Cannot index into a null array.
$srcObj and $commonParameters.CommonVars.SourceObject both function as expected.
This is by design.
The Quick Connect and Active Roles Synchronization Service perform mapping on an a per-object basis. It is multi-threaded, but essentially, the mapping criteria of an object from the source connected system is compared to the mapping criteria of every object from the destination connected system in order to see if there is a match. Because of this, the destination connected system mapping criteria cannot be a computed value - every value has to be available for an immediate comparison.
In order to remain flexible and scalable, it is not feasible to change this behaviour so that computations are performed on all objects of a connected system before a comparison is made.
Only use $srcObj and $commonParameters.CommonVars.SourceObject to retrieve and perform calculations on objects which reside in the source domain when configuring Mapping.