Here’s something I’ve been promising to post for a while – my BPOS Powershell Activity.
It’s designed to work with the Function Evaluator
The first point to note is that, unless you’re running a script or cmdlet that takes no parameters, you’re going to have to generate a parameter string. For BPOS this will include the BPOS Identity as a minimum. I use the Function Evaluator ahead of this activity to generate my powershell parameter string, which I then pass to the powershell activity through WorkflowData.
The Parameter string must be in an expected format
My activity only supports parameter strings in the format “-Param ‘Argument’ -Param ‘Argument'”.
- Scripts using the arg(0), arg(1) method are not supported.
- String arguments only.
- All arguments have to be enclosed in single-quotes, even if you don’t have to do this when running the cmdlet directly in powershell.
Using the Activity
- Enable/Disable activity
- Logging to Application Event Log
- Workflow type:
- Action: activity completes irrespective of powershell return value,
- AuthZ: activity fails if powershell returns an error.
- Name of powershell cmdlet or full path to script
- Specify plugin (in case using another library, eg., MessageOps)
- Parameters passed via WorkflowData parameter generated earlier (see above).
- Specify WorkflowData parameters to return the result of the powershell command (“Succeeded”,”Failed”) and/or a detailed message. These can then be used in a subsequent activity, such as a Notification.
- Reverse simple changes in certain cases eg.,
- Clear a change password attribute on both success and failure,
- Clear a check box if the requested change failed.
- If using Remote Powershell specify the remote server name and connection details. Assumes “localhost” if left blank.
- Specify BPOS username and password of an administrator account.
- Note that passwords must be re-entered whenever the activity is edited.
You can download a copy of the activity here.
Please note you will need to fix the references and compile it yourself.
This code is provided as an example only with no warranty or support. It may not be applicable for your environment. Make sure you understand it and adapt it appropriately.