I'm no PowerShell-guru and it took me some time to get my scripts to behave well in workflows.
For that reason, I am missing a list of good practices when writing such scripts. Documentation is missing...
Would like to start this discussion so that we can learn from each other.
Some of my own experiences (to get the snowball rolling):
Script calls to *-Host cmdlets will fail, since the scripts are running in an odd runspace within the .Net 4 Workflow Foundation.
A call to write-host for logging or other purposes, may work some times, but run multiple concurrent activities and it will definitively fail with:
“Cannot Invoke this function because the current host does not implement it”
The same error message will appear if the cmdlet requires a confirmation, so make sure to force it through:
Remove-ADGroup -Identity myTestGroup -Confirm:$false
Be careful with the use of "continue" in try/catch blocks or loops. It may easily exit your script earlier than planned.
Don't forget that the activities are running asynchronous and in parallel - race conditions will occur.
Helpful blogs:
http://cloudyautomation.com/category/vcac-external-workflows/