0 votes

Hi all, I need to update, during business rules, a custom Attribute with the last 5 characters from an other custom Attribute. EX: employeeNumber = 0123456789 adm-CustomAttributeText13= empty

UPDATED employeeNumber = 0123456789 adm-CustomAttributeText13= 56789

I tried with adaxes powershell script but I received an error in substring function, can you help me?

Thanks in advance

by (430 points)

1 Answer

0 votes
by (288k points)
selected by
Best answer

Hello Simone,

Here is the script you need to use. In the script:

  • $sourcePropertyName – Specifies the LDAP name of the property, whose value will be cut.
  • $targetPropertyName – Specifies the LDAP name of the property to update.
  • $charNumber – Specifies the number of the last characters to be taken from the property value for another one.
$sourcePropertyName = "employeeNumber" # TODO: modify me
$targetPropertyName = "adm-CustomAttributeText1" # TODO: modify me
$charNumber = 4 # TODO: modify me

# Get source property value
try
{
    $sourceValue = $Context.TargetObject.Get($sourcePropertyName)
}
catch
{
    $Context.LogMessage("Property $sourcePropertyName is empty.", "Warning")
    return
}

# Update target property
$targetValue = $sourceValue.SubString($sourceValue.Length-$charNumber)
$Context.TargetObject.Put($targetPropertyName, <#PROPERTY-VALUE#>)
$Context.TargetObject.SetInfo()

Related questions

0 votes
1 answer

Dear Is it possible to change the values of a custom attribute (adm-CustomAttributeTextMultiValue4) when selecting a value from another custom attribute (adm-CustomAttributeText1). For ... , 2Latijn, 3Latijn, etc... Is this possible? Sincerly Hilmi Emre Bayat

asked Aug 26, 2019 by hilmiemrebayat (120 points)
0 votes
1 answer

Is it possible to export Business Rules and/or Custom Command, from the Admin Console, so that we can have a backup of the current setup? I especially want to have a document of the Custom Commands and their IDs, which I'm using in PowerShell scripts.

asked Feb 26, 2014 by sdavidson (730 points)
0 votes
1 answer

I have a question: I have a security role that allows specific users to modify "extensionattribute2" in AD. Is it possible to create an approval for this that would ... manager of the target account to approve the change before it is really applied? Thanks!

asked Jan 16, 2012 by BradG (950 points)
0 votes
1 answer

Thanks for the info. I'm now grabbing the %adm-ManagerUserName% value, but need to remove the final 21 characters of it so it contains only their username and not our ... this in the PowerShell Script Editor for my business rule, I get the following error:

asked Mar 11, 2021 by mkvidera (60 points)
0 votes
1 answer

In our environment, we have many business rules with "Add to group". Now I have to delete the "Add to group xyz" in all business rules, as the group is now rule-based. Is there ... in Adaxes so that I don't have to search for and delete all "Add to group xyz"?

asked Mar 7 by DRiVSSi (300 points)
3,538 questions
3,229 answers
8,224 comments
547,747 users