0 votes

I had a business rules that had a PowerShell script to update User properties in a SQL table. It was working fine.

I moved the PowerShell to a custom command so I could use it in multiple business rules. But now the PowerShell in the custom command does get the values for the User object.

Am I missing something?

by (730 points)
0

Hello,

Can you post the PowrerShell script that you use here or send it to our support e-mail (<support[at]adaxes.com>)?

0

Thank you I just emailed the script

1 Answer

0 votes
by (215k points)

Hello,

The thing is that in your script, you use the $Context.GetModifiedPropertyValue method to get the values entered by users. It works in Business Rules, because Business Rules are triggered by a certain operation (creating a user or updating a user), and the values are modified or set by that operation. However, when you call a Custom Command from your Business Rule, this is a completely different operation, and it doesn't modify any values. It only runs a Custom Command. That's the reason why the $Context.GetModifiedPropertyValue method fails.

0

OK, I understand. So, in my situation how can I solve my problem?

I need to run the update script only when some of the properties are modified. And I need to call this from multiple Business Rules.

Is there no way to do it other than by duplicating the script in the Business Rules?

0

Could you describe in a bit more detail what task you want to achieve with the Business Rules and when are the Business Rules triggered? As far as we understand, your Rules are triggered before the main operation (e.g. before updating a user). This is not a good idea at all because if an operation fails for some reason (for example, if the initiator doesn't have sufficient access rights), the values specified by the user will not be saved to the AD, but will be saved to the SQL database anyway.

Related questions

0 votes
1 answer

Is it possible to have custom command that doesn't execute on a specific (or any) AD object? I realize Adaxes is for AD management, but I was wondering if it would be ... to execute against and AD object, I just need it to talk to the SQL server. Thanks

asked Nov 9, 2012 by bemho (520 points)
0 votes
1 answer

Can you run a powershell to get a Custom Command's ID?

asked Jun 10, 2020 by hgletifer (1.2k 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 by davfount90 (20 points)
0 votes
1 answer

I am wanting to export a list of users including the properties of a specific custom attribute. Ideally, I would be able to run a get-admuser and filter on a custom attribute, but even an excel report with the custom attributes would work. Is this possible?

asked Sep 9 by ggallaway (300 points)
0 votes
1 answer

Hi there, i've a custom command with multiple powershell scripts (for clearance reasons). If for example the frist script produces an error i Write an Error but the next ... tried with an simple exit 1; I only Write-Errors on issues. Kind regards, Constantin

asked Jul 23 by Constey (170 points)
2,575 questions
2,318 answers
6,176 comments
769,417 users