0 votes

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

by (2.0k points)

1 Answer

0 votes
by (289k points)
selected by
Best answer

Hello Matt,

The issue occurs because at least one of the values in one of the arrays you are attempting to save to the custom multi-valued attributes is exactly $Null. You need to add a check for that to validation of the values being added to the arrays.

Also, you can use the required filter directly when calling the Get-ADUser cmdlet instead of using Where-Object. For details, have a look at the description of the -Filter and -LDAPFilter parameters in the following Microsoft article: https://docs.microsoft.com/en-us/powershell/module/addsadministration/get-aduser?view=windowsserver2019-ps.

Should you have issue updating the script, please, describe the desired behavior in all the possible details with live examples.

0

Thanks for that, works perfectly once I filtered out the null entries.

Matt

Related questions

0 votes
0 answers

Here is an example: In Azure the manager shows populated: In Adaxes it shows a blank:

asked Dec 2, 2022 by adaxes_user2 (40 points)
0 votes
0 answers

Hi All, I have setup an action to cancel all meetings in outlook when a user is leaving. We use Exchange online but I'm getting an error 'The operation is supported by Exchange online and Exchange versions starting from 2019' I cant see where you specify.

asked Sep 6 by DarrenFisk (60 points)
0 votes
1 answer

We use TOPdesk as our ITSM solution. Several departments are able to create new users. When a create user task fails we would like to receive the alert as the Adaxes ... Adaxes to sent out the incident to our TOPdesk. Is there a solution for this?

asked Oct 5, 2023 by mrkvd16 (50 points)
0 votes
1 answer

Hi, I'm trying to add a column to a report to retrieve the last login data from AAD/Graph using the script posted here but i'm running into the ... [0].signInActivity.lastSignInDateTime # Assign a column value to $Context.Value $Context.Value = $lastLogonDate

asked Feb 22, 2022 by richarddewis (260 points)
0 votes
1 answer

Hi, we're receiving the below error when trying to add SMTP addresses to Office365 mailboxes from Adaxes. I've raised a ticket with support, but thought I'd ask ... , please see exception members for more information. Any help would be great. Thanks Gary

asked May 29, 2020 by gazoco (490 points)
3,549 questions
3,240 answers
8,232 comments
547,826 users