0 votes

Trying to remove the Aprostrophe from a name in several different area's, "samAccountName", "userPrincipalName", "mail" using this script run before user creation, but it's not working.

Example, change the name O'Connel, to OConnel.

I run a similar script but it removes spaces and works well.

$properties = @("samAccountName", "userPrincipalName", "mail") # TODO: modify me

foreach ($property in $properties)
{
    if ($Context.IsPropertyModified($property))
    {
        $value = $Context.GetModifiedPropertyValue($property)
        if ($value.Contains(" "))
        {
            # Remove apostrophe
            $value = $value.Replace("'", "")

            # Update property
            $Context.SetModifiedPropertyValue($property, $value)

            # Log message
            $Context.LogMessage("Spaces have been removed from $property", "Information")
        }
    }
}
by (5.4k points)

1 Answer

0 votes
by (174k points)

Hello,

The thing is that in the if statement your script checks whether a property value contains spaces and only then removes apostrophes. If the value does not contain spaces, it will not be updated. For the script to work, please, replace this line in your script

if ($value.Contains(" "))

with the following one:

if ($value.Contains("'"))

0

Thanks, totally missed that!

Related questions

0 votes
1 answer

Adaxes version is 2018.2. I have build a custom report, and I don't want the 'Name' column with the pictures to appear in it. But it seem to be mandatory, it is greyed ... . Is there a way to remove / hide / or change the mandatory attribute or column ? Thanks

asked Jan 9 by Isabelle (280 points)
0 votes
1 answer

HI Support, I'm looking for a business Rule that remove a user from a couple of groups after the User is added to a group. ie 1. The User MaxMi is added to the ... not able to create a powershell scripts for removing the added user from the other Groups. Thx,

asked Jan 4, 2016 by Napoleon (4.9k points)
0 votes
1 answer

How do change the display name of a custom attribute in version 2017.2? All the information I am finding contains links that bring me to 2018 version

asked Nov 1, 2018 by hgletifer (5.8k points)
0 votes
1 answer

Hello, is it possible to change the name (view) of a custom attribute in the WebUI? thx.

asked Jan 25, 2012 by mmichard (3.7k points)
0 votes
0 answers

By default, Web Interface URLs look like the following: http://host.company.com/Adaxes/HelpDesk. For the URLs not to contain the Adaxes part: On the computer where Adaxes ... C:\Program Files\Softerra\Adaxes 3\Web Interface by default. Click OK. Restart IIS.

asked Oct 30, 2019 by Support2 (174k points)
2,135 questions
1,900 answers
5,319 comments
3,530 users