Run Multiple Powershell Scripts Sequentially - on a Folder - Combine Scripts into a Master Script

后端 未结 6 2020
花落未央
花落未央 2021-02-05 08:25

I have 6+ scripts and growing to run on a folder, what is the best way to have them run one after the other.

I have seen and tried this thread - it did not work unfortun

6条回答
  •  梦如初夏
    2021-02-05 09:20

    The reason why the powershell screen pops up is cuz you dont have the argument -NoExit set. Please use the following as an example to see if your code is running properly:

    Start-Process "$pshome\powershell.exe" -ArgumentList "-NoExit", "-Command '& script'" -wait
    

    Sorry for the late response but I also ran into the issue and thats how I was able to resolve it to make sure it was work.

    Also I changes the file names as follows:

    $Scripts =
    @(
     ".\C:\Scripts\First.ps1"
     ".\C:\Scripts\Second.ps1"
     ".\C:\Scripts\Third.ps1"
     );
    

提交回复
热议问题