Error control loops and workflows

MrFlinstone 581 Reputation points
2021-06-23T23:46:16.77+00:00

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,551 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ian Xue 37,621 Reputation points Microsoft Vendor
    2021-06-24T05:13:03.577+00:00

    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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.