A Business Rule cannot be launched manually, it can be triggered only by the event before/after which it is configured to be run. Also, a Business Rule cannot be configured to be launched by two different events simultaneously.
However, you can achieve what you want with the help of a Custom Command. You can create a new Custom Command and move all the actions and conditions of Business Rule [2] to the Custom Command.
Then, you can call your Custom Command both from the Business Rule triggered after user creation and from your PowerShell script.
To create a Business Rule that executes a Custom Command after user creation:
- Create a new Business Rule.
- On the 2nd step of the Create Business Rule wizard, select User and After Creating a User.
- On the 3rd step, add the Execute Custom Command action and click Select.
- Select the Custom Command you need.
To launch a Custom Command from a script, you need to use the ExecuteCustomCommand method exposed by the object for which you want to execute the Command. To execute a Custom Command on a target object of a Business Rule, Custom Command or Scheduled Task, you need to use the built-in $Context variable, for example:
$target = $Context.BindToObjectEx($Context.TargetObject.AdsPath, $true)
$target.ExecuteCustomCommand($customCommandId)
$customCommandId is the ID of a Custom Command. For information on how to get it, see the following SDK article: http://www.adaxes.com/sdk/?HowDoI.GetCu ... andID.html.