question

MrFlinstone-1451 avatar image
0 Votes"
MrFlinstone-1451 asked IanXue-MSFT edited

Error control loops and workflows

I have got a powershell script which accepts a list of servers in an array as a parameter, let us assume a list of 10 servers are passed

The array is passed onto a workflow.

The workflow uses the parallel functionality to operate on multiple servers at once.

The workflow uses an inline script.

For every server called in the foreach parallel within the workflow, invoke-sqlcmd will be called to deploy 5 files.

How can the error action be changed such that for every server, if there was a failure on server 3, the script should move onto server 4. however if there is an error on script number 3 out of the 5 script files deployed per server, the deployment should stop onto that SQL server but move onto the next one ?


windows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered IanXue-MSFT edited

Hi,

To my knowledge, the InlineScript sessions running in parallel do not communicate with each other. You may try to set ErrorAction to stop in your scripts and handle the errors using try/catch blocks in which the script can be manually deployed on other servers.

Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.