Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling Powershell Script from Powershell Shell 1

Status
Not open for further replies.

st0smith

Programmer
Dec 1, 2007
1
US
I am trying to port a series of Korn shell scripts to Powershell. I wrote a series of Powershell scripts, including one master script that calls all the others. I am having trouble calling any of the other scripts. If there is an error in the called script, the error shows, but if there is no error, the called script does not run. I am using the invoke-expression command to call them. Is this incorrect?
ex:
switch ($rChoice)
{
1 {invoke-expression custmnt; break}
2 {exit}
}

Steve
 
I wrote a series of Powershell scripts, including one master script that calls all the others.
Suggestion:
Using "dot-source" to call other PowerShell scripts from a Master PowerShell script. Here is an excerpt from an article I wrote on using Functions and Dot-Source to call other scripts. May be useful for what you are attempting:

another viable way to call items from your script library. Essentially, "dot-source" means using dot-notation to call script blocks, functions, and/or aliases from within your script. We're going to use the same script examples above, but instead of calling the function written within the script, we will use dot-notation to call other scripts that exists outside the main script...

Full article here:

Jesse Hamrick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top