Hi,

would it be possible to use Value references in embedded scripts with functions?

Like, I have several flows, using one external shared file with PowerShell functions.

If I call now a function within Adaxes like the following, how can I ensure the values are replaced correctly?

# Function to replace placeholders
function Replace-Placeholders($address) {
    return ReplaceCharacters_mail $($address.Replace("firstname", "%firstname%").Replace("lastname", "%lastname%").Replace("sAMAccountName", "%sAMAccountName%").Replace(" ", ""))
}
ago by (2.3k points)

1 Answer

ago by (306k points)
0 votes

Hello,

Sorry for the confusion, but we are not sure what exactly you mean by embedded scripts with functions. At the same time, all scripts in Adaxes first get value references resolved and only then are executed. However, value references never work in scripts executed externally (e.g. natively in Windows PowerShell).

ago by (2.3k points)
0

I have a business rule script that dot-sources an external PowerShell function file:

. \\server\path\functions.ps1

Within the external functions.ps1 file, I have a function that attempts to use Adaxes value references like %firstname% and %lastname% to build email addresses or other values based on user properties.

Problem: The value references are not being resolved when used within functions defined in the external file. Instead of getting the actual user values, the function returns literal strings like %firstname%.%lastname%@domain.tld.

Question: Do Adaxes value references (e.g., %firstname%, %lastname%) work within functions that are defined in external PowerShell files and then dot-sourced into business rule scripts?

I've tried:

  • Single percentage signs: %firstname%
  • Double percentage signs: %%firstname%%

Neither approach resolves to the actual user values.

Current Workaround: If this functionality is not supported, I can modify my approach to pass the actual values directly to the function as parameters instead of relying on value references within the external function.

Could you please clarify whether this is expected behavior or if there's a supported way to use Adaxes value references within dot-sourced external functions?

ago by (306k points)
+1

Hello,

Thank you for the clarification. The behavior is expected. Value references only work when used in Adaxes scripts explicitly. In your particular case, the approach with parameters for functions is something that should work just fine.

Related questions

Hello again, I am setting up the Web Console so our support people can add users to groups. Currently when they go in they can select a user from all the users they can ... into the web portal. Is there a way to pull value references from the selected object?

asked Mar 25, 2016 by drew.tittle (810 points)
0 votes
1 answer

Hello! I would like to use the utc parameter that is described in value references - date/time formatting (https://www.adaxes.com/help/ValueReferences/). The goal is ... please indicate whiich would be the right way for using the utc switch? Thanks, Fabiano

asked May 3, 2024 by fabiano.santos-agco (20 points)
0 votes
1 answer

We have created a workflow for creating user accounts and would like the manager of the new user to be the approver for the account but the account is not created until it is ... to use a parameter as an approver. Is there a powershell way to do this maybe?

asked Jan 24, 2020 by mark.it.admin (2.3k points)
0 votes
1 answer

Hi We create different Groups when a new OU is generated. The name of the groups consist of the OU name with additional text. We would like ... value $Context.SetModifiedPropertyValue($property, $value) $Context.LogMessage($value, "Information") Thanks, Mario

asked Jul 9, 2020 by maca (100 points)
0 votes
1 answer

We are using the below snippet to grab the email of a single custom attribute object. Can I get guidance on the best way to modify this to get all the emails of each ... "The user specified in parameter 'MyParameter' has no email address. ", "Information") }

asked Dec 23, 2024 by msheppard (880 points)
0 votes
1 answer