Hello,
Thank you for clarifying. To achieve the desired, use the below script. To execute it, create a business rule, custom command or scheduled task. In the script:
- $textToReplace - the test to replace in business rule names.
- $textToSet - the text to set into business rule names during replacement.
$textToReplace = "123France - Create" # TODO: modify me
$textToSet = "France - Update" # TODO: modify me
# Search parameters
$rulesContainerPath = $Context.GetWellKnownContainerPath("businessRules")
$searcher = $Context.BindToObject($rulesContainerPath)
$searcher.Criteria = New-AdmCriteria "adm-BusinessRule"
$searcher.SearchScope = "ADS_SCOPE_SUBTREE"
$searcher.PageSize = 500
$searcher.ReferralChasing = "ADS_CHASE_REFERRALS_NEVER"
try
{
# Execute search
$searchResultIterator = $searcher.ExecuteSearch()
$searchResults = $searchResultIterator.FetchAll()
foreach ($searchResult in $searchResults)
{
$rule = $Context.BindToObjectBySearchResult($searchResult)
$ruleName = $rule.Get("name")
# Update business rules.
if ($ruleName -like "*$textToReplace*")
{
$ruleName = $ruleName.Replace($textToReplace, $textToSet)
$rule.Put("name", $ruleName)
$rule.SetInfo()
}
}
}
finally
{
# Release resources
if ($searchResultIterator){ $searchResultIterator.Dispose() }
}