Run Powershell scripts sequentially

This topic contains 3 replies, has 3 voices, and was last updated by  Bin Ary 4 years, 6 months ago.

  • Author
  • #11845

    Bin Ary

    I have 3 script files file1.ps1,file2.ps1,file3.ps1 to be run one after one but only if the precedence script succeeded succesfully
    how can i do that, i want to wrap the 3 filoe script in one operation.
    thanks in advance

  • #11846

    Richard Siddaway

    How are you determining success?

    I'd wrap the 3 scripts in another script and pass the success/failure details back to that.

    A better approach would be to convert the 3 scripts to functions then you can have a controlling script that the functions can pass success/failure to

  • #11847

    Don Jones

    Agreed. It'd be far better to build the sub-scripts into functions, which your "main" script can then call. Functions can return errors (Write-Error or Throw), which the main script could trap. Functions could also just return a good/bad return value, so the mains cript would know.

  • #11848

    Bin Ary

    thank you

You must be logged in to reply to this topic.