Hi
I'm having an issue saving some arrays to multivalue attributes in a scheduled task script and I cannot see what the issue is.
Import-Module ActiveDirectory
$domains = (Get-ADForest).domains
$departments = @()
$countries = @()
$companies = @()
foreach ($domain in $domains) {
Get-ADUser -Filter * -Server $domain -Properties co, company, department, employeeid, enabled |
Where-Object { $NULL -ne $_.employeeid -and $_.enabled -eq $true } |
ForEach-Object {
if ($departments -notcontains $_.department) { $departments += $_.department }
if ($countries -notcontains $_.co) { $countries += $_.co }
if ($companies -notcontains $_.company) { $companies += $_.company }
}
}
$Context.TargetObject.PutEx("ADS_PROPERTY_UPDATE", "adm-CustomAttributeTextMultiValue7", $companies)
$Context.TargetObject.PutEx("ADS_PROPERTY_UPDATE", "adm-CustomAttributeTextMultiValue8", $countries)
$Context.TargetObject.PutEx("ADS_PROPERTY_UPDATE", "adm-CustomAttributeTextMultiValue9", $departments)
$Context.TargetObject.SetInfo()
The issue is that when the SetInfo is called, I get the error
Exception calling "SetInfo" with "0" argument(s): "Value cannot be null. Parameter name: value" Stack trace: at , : line 19
What I don't understand is in another script I have the same PutEx and SetInfo commands using multvalue attributes and arrays and this works perfectly.
I know that the array's have values, I've added log messages to the script to check the count of each array.
I've tried using a single SetInfo and commenting out all but one array and corresponding PutEx's, but the same end result.
We're running Adaxes 3.13.18001.0.
Both this and the working scripts are running against single user objects (different users) on the same Adaxes server, neither user objects have been excluded from Adaxes management and both are in the same domain.
Any help will be much appreciated.
Thanks
Matt