0 votes

I have the need to run a scheduled task that executes a PowerShell script to update the user criteria item on a rule-based group. I have a good start on the script, but wondered if any PowerShell wizzards could assist me. It's just taking me a long time to understand the adaxes interfaces, their methods and all that. Any help would be apprecaited.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")

# Bind to the group
$groupDN = "%distinguishedName%"
$group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0)

# returns criteria
$rules = $group.MembershipRules

foreach($rule in $rules){
    $criteria = $rule.GetCriteria()

    <# Find the user criteria item in the array that is:
        Add({employeeType -eq "Full-Time Employee" -or employeeType -eq "Part-Time Employee" -or employeeType -eq "Limited Term Employee" -or employeeType -eq "Intern"}).
        and replace with:
        Add({employeeType -eq "Full-Time Employee" -or employeeType -eq "Part-Time Employee" -or employeeType -eq "Limited Term Employee" -or employeeType -eq "Intern" -or employeeType -eq "Regular" -or employeeType -eq "Temporary" -or employeeType -eq "Seasonal" -or employeeType -eq "Elected" -or employeeType -eq "State"}). 
     #>

}
by (160 points)

1 Answer

0 votes
by (15.9k points)

Hello,

Unfortunately, there are no such scripts in our repository. It should be possible to get the criteria from a membership rule (you can get the criteria for a certain object type using the GetCriteriaFor method) and convert it to Json (https://www.adaxes.com/sdk/IAdmConfigObjectJson/#ToJson_details). Then you can build the criteria you are searching for, convert it to Json as well, and use it to compare with the Json criteria in the membership rule. For more details about the criteria class, have a look at the following SDK article: https://www.adaxes.com/sdk/Criteria.

Related questions

0 votes
1 answer

Hi, I would like to exclude users from a rule-based group where distinguishedName contains "Special". Any possibility to achive this?

asked Jul 4, 2023 by wintec01 (2.0k points)
0 votes
1 answer

I have found the script to force membership updates for all rule based groups, but is there a script to force update a specific rule based group? I am looking to add a ... I would like to trigger a rule based group that adds members of the manual group. Thanks

asked Jul 9 by msheppard (840 points)
0 votes
1 answer

Receive "Index operation failed; the array index evaluated to null. Stack trace: at &lt;ScriptBlock&gt;, &lt;No file&gt;: line 104&gt;" and "Index operation failed; the ... $GroupName, $GroupDN." } } #foreach write-output "" Write-Output "" Stop-Transcript

asked Apr 14, 2022 by jbahou (20 points)
0 votes
1 answer

Update group membership based on one property values. I am trying to find a script that resembles "Update group membership based on two property value" but just for one value.

asked Apr 7, 2022 by lee_thomas (20 points)
0 votes
1 answer

I am trying to build a custom command to add a specific user to a rule based group in adaxes and I am curious if it is something we can use the API to complete?

asked Mar 7 by Brian (40 points)
3,731 questions
3,409 answers
8,625 comments
550,199 users