Run Powershell scripts sequentially

Welcome Forums General PowerShell Q&A Run Powershell scripts sequentially

This topic contains 3 replies, has 3 voices, and was last updated by

5 years, 4 months ago.

  • Author
  • #11845

    Points: 0
    Rank: Member

    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

    Points: 0
    Rank: Member

    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

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    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

    Points: 0
    Rank: Member

    thank you

The topic ‘Run Powershell scripts sequentially’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort