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 (100 points)

1 Answer

0 votes
by (14.1k 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 (1.5k 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

When setting up a rule based group, GMSA objects are not visible. Is there a setting or view I need to add to make these availabe to rule based groups, or is it simply not an option?

asked Sep 16 by ajmilic (100 points)
0 votes
1 answer

I have a Rule-Based group with users. Every time a users gets added or removed from this group I want to trigger a Business Rule for "Atter adding or removing a member ... Rules be triggered by a Rule-Based group adding or removing a user? Morten A. Steien

asked Mar 27, 2023 by Morten A. Steien (300 points)
3,548 questions
3,238 answers
8,232 comments
547,814 users