The script forces membership update for all the existing rule-based groups. To execute the script, create a custom command, business rule or scheduled task configured for the required object type.
PowerShell
# Search parameters
$searcher = $Context.TargetObject
$searcher.Criteria = New-AdmCriteria "group" {membershipType -eq "rule-based"}
$searcher.SearchScope = "ADS_SCOPE_SUBTREE"
$searcher.PageSize = 500
$searcher.ReferralChasing = "ADS_CHASE_REFERRALS_NEVER"
$searcher.VirtualRoot = $True
try
{
# Execute search
$searchResultIterator = $searcher.ExecuteSearch()
$searchResults = $searchResultIterator.FetchAll()
foreach ($searchResult in $searchResults)
{
# Update group membership
$group = $Context.BindToObjectBySearchResult($searchResult)
$group.UpdateMembershipNow()
}
}
finally
{
# Release resources
if ($searchResultIterator){ $searchResultIterator.Dispose() }
}