Error control loops and workflows

MrFlinstone 481 Reputation points

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
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,357 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 29,491 Reputation points Microsoft Vendor


    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.

    0 comments No comments