0 votes

Hello How can I use a script to search for "123France - Create" in the business rules and replace the "123France - Create" with "France - Update"? This would be an example of searching for "123France - Create": Adaxes://AI0ADX1.FRANCE.com/CN=123France - Create - Collaborateur administratif,CN=Administration,CN=Service,CN=FRANCE,CN=Business Rules,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes And this should be done throughout the CN=Business Rules. It will always be searched for "123France - Create".

by (280 points)

1 Answer

0 votes
by (272k points)

Hello,

have a look at the following script from our repository: https://www.adaxes.com/script-repository/search-and-replace-text-in-adaxes-scripts-s224.htm.

0

Ok thank you. However, I do not want to search in scripts, but in the names of the BusinessRules. I have a BusinessRule called 123France - Create - Collaborateur administratif. I would like to replace the name of the BusinessRule

0

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() }
}
0

That's so great.

Thank you so much for your support. Very nice!

Have a nice weekend

Related questions

0 votes
1 answer

I am trying to use this script from the script repository: https://www.adaxes.com/script-repository/enable-mfa-with-phone-number-for-a-user-in-microsoft-365-s686.htm I ... if I just didn't install it correctly because Adaxes Powershell doesn't recognize it.

asked Oct 10, 2023 by ocanizales (40 points)
0 votes
1 answer

If the user name submitted is "jhon doe" all of the users properties will be lower case. We want it to force it to be "Jhon Doe" even if it was submitted in lower case.

asked Aug 31, 2022 by raul.ramirez (210 points)
0 votes
1 answer

Is there a way to get the name of the user who approved a request and supply that to a step inside of a custom command? For example, HR submits a status change for an employee. ... and pass it as a param in a custom command that is called in one of the steps?

asked May 12, 2021 by davfount90 (20 points)
0 votes
1 answer

The account is configured with the user's email address as its name and the icon says third party.

asked Aug 19, 2021 by bsteele (90 points)
0 votes
1 answer

Are we able to add any new filter items in the pull down window to add columns after running a search? If so how can we do this? If not when could this be added?

asked Jun 13, 2014 by babbeaw (320 points)
3,351 questions
3,052 answers
7,791 comments
545,092 users