Call PowerShell script PS1 from another PS1 script inside Powershell ISE

I want call execution for a myScript1.ps1 script inside a second myScript2.ps1 script inside Powershell ISE.

The following code inside MyScript2.ps1, works fine from Powershell Administration, but doesn’t work inside PowerShell ISE:

#Call myScript1 from myScript2
invoke-expression -Command .\myScript1.ps1

I obtain the following error when I execute MyScript2.ps1 from PowerShell ISE:

The term ‘.\myScript1.ps1’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

13 Answers
13

Leave a Comment