PowerShell Connector handling of DN.multi attributes where there is a single value
The PowerShell Connector treats DN.multi attributes with a single value differently to how it treats string.multi attributes with a single value. This can be overcome in the script however unnecessarily complicates import the script.
Error if handled the same as a string.multi (appears to take first char rather than first array entry):
Script that will handle the single value: StudentParentRelationshipsImport.ps1
DN.multi attribute: ParentRelationshipDNs
String.multi attribute: ParentIDLIST
Identity Broker: v5.0.5
Answer
Hi Boyd,
Are you able to supply a minimum reproducible example? The following two methods for adding a single value to a multi-value distinguished name should work.
Import Script:
$entity = $entities.Create() $entity['ID'] = 10002 $dns = @() $dns += 'CN=1' $entity['A'] = $dns $entity['B'] = @('CN=2') $entity.Commit();
Schema:
New-Field 'ID' 'string' $true $false $true; New-Field 'A' 'dn.multi' $false $false $false; New-Field 'B' 'dn.multi' $false $false $false;
Hi Curtis
I have been experimenting and found it is cased by performing the Sort (eg $Attribute | Sort) before the import and that it is not limited to DNs. I suspect the Sort is changing the array object somehow. As I need to sort the list and ensure it is unique I process it before importing to the $entity.
Boyd
Hi Boyd,
This appears to be a peculiarity with PowerShell.
$array = @('A') $array.GetType() # Object[] $sort = $array | Sort $sort.GetType() # String $sort = @($array | Sort) $sort.GetType() # Object[]
Please make sure that you force your value into an array before assigning to multi-valued fields.
Customer support service by UserEcho
Hi Boyd,
This appears to be a peculiarity with PowerShell.
Please make sure that you force your value into an array before assigning to multi-valued fields.