i have a powershell script that loads other powershell scripts. when i run this script in a powershell session, it runs fine. however, if i run it from a standard command window, any functions defined in the secondary powershell scripts are no longer recognized!? anyone familiar with this problem and how to get things working?
for example:
main powershell script: main.ps1
include file: test1.ps1
then, from a standard command window (the idea is that a batch file will be launching this), i run...
at this point, it will display an error that term "function1" is not recognized. however, if i open a powershell session and run...
it runs fine. any suggestions?
glenn
for example:
main powershell script: main.ps1
Code:
& '.\test1.ps1'
cls;
function1;
include file: test1.ps1
Code:
function global:function1()
{
write-host "in function 1";
}
then, from a standard command window (the idea is that a batch file will be launching this), i run...
Code:
powershell -command "& {main.ps1}"
at this point, it will display an error that term "function1" is not recognized. however, if i open a powershell session and run...
Code:
.\main.ps1
it runs fine. any suggestions?
glenn