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

 
Participant
5 years ago.

  • Author
    Posts
  • #11845

    Participant
    Points: 0
    Rank: Member

    hello
    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

    Participant
    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

    Keymaster
    Points: 1,704
    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

    Participant
    Points: 0
    Rank: Member

    thank you

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