Call /execute powershell script from inside another script

I have a Main Powershell Script that looks at a text file with headers of computername, service, script. The script looks at the machines under computer name then checks the service listed for each computer and either stops or starts the service based on the request. That part is working However I also have an elseif($computer.script -eq "script") function that I would like to use to pull in an external script and execute it.. So My txt file is like
 Im trying to understand how to pull in that external script and then execute it, in a format like follows.
 elseif($computer.operation -eq "script")
    # run external script.

Where I am running into issues is with how to pull in an external script and running it correctly. I thought about using something like an:
Invoke-Expression    <-- But I am not sure how to do that if each line that has a server name has a different script (in this case I may want to use a script for resetting ColdFusion Services on one server but a different external script for something else on a different server)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Giovanni HewardCommented:
One method:

$str = [IO.File]::ReadAllText(".\External_script.ps1")
Invoke-Expression $str

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Legacy OS

From novice to tech pro — start learning today.