How to Run Multiple PowerShell Scripts Sequentially from Different Folders?

0
10
Asked By TechieDreamer42 On

Hey everyone! I'm diving into PowerShell scripting and could use some help with a setup I have. I've created a main PowerShell script intended to run other scripts that are located in separate subfolders. The idea is to execute scripts like code1.ps1, code2.ps1, etc., in a specific order, ensuring each script finishes before the next one kicks off.

The problem I'm running into is that despite using the -Wait command, it seems to stall at the last executed script, and I'm required to manually close the window to proceed with the next one. I also tried using -NoExit, but I get an error saying that parameter can't be found.

Here's a snippet of my main script for reference:
...
Can anyone guide me on how to fix this? I appreciate any tips or advice!

1 Answer

Answered By ScriptingSavvy77 On

Instead of using `& start powershell {.code1.ps1} -Wait`, just go with `. .code1.ps1`. This will execute the script in the current context and should resolve your issue. Repeat this for the other scripts as well!

PowerShellNoob -

Thanks for the tip! Code is running smoothly right now. I’ll keep you updated if it all completes correctly!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.