Full Stack LAMP - MEAN Developer, Python developer. Certified Azure Developer. Freelance programmer/consultant/trainer.

Call PowerShell Script PS1 from Another PS1 Script

To call a PowerShell script (PS1) from another PowerShell script (PS1), you can use the & operator followed by the path to the script file. Here’s an example:

# Contents of the main script (main.ps1)

# Call the other script
& "C:\path\to\otherScript.ps1"

In the above example, replace "C:\path\to\otherScript.ps1" with the actual path to your other script file.

When you run the main script (main.ps1), it will invoke and execute the other script (otherScript.ps1 in this case). The main script will continue executing after the other script completes unless there are any exit statements or exceptions thrown within the other script.

Make sure you provide the correct path to the script you want to call and ensure that the execution policy is set to allow running scripts if necessary.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments