Skip to content

Call PowerShell Script PS1 from Another PS1 Script

Last updated on July 17, 2023

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.

5 1 vote
Article Rating
Notify of

Inline Feedbacks
View all comments