Preparting environment for running a powershell script

I needed to schedule a powershell script and before doing it, i needed to prep the environment by running some other powershell script.

Basically i wanted to run

PowerShell.exe -noexit " & ' C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14CONFIGPOWERSHELLRegistrationsharepoint.ps1' "

PowerShell.exe -command " & ' E:PerfCountersPowershellRunPerf.ps1' "

The first statement will perp my environment and i want to execute my own script after that.

Issue is, if i use the -noexit command, the next script never gets executed. If i use -command instead of -noexit, the commands seems to be executed in different powershell instances so my second script is erroring out.

I am a newbee in powershell and i did my best tring to find a answer. Any help here would be really appreciated. thanks!


如果你没有自己解决这个问题,或者如果其他人需要这个语法,那么你可以这样做:

powershell -noprofile -command "& { & .x.ps1; & .z.ps1 }"
链接地址: http://www.djcxy.com/p/29036.html

上一篇: 在PowerShell 2.0中加载.NET 4.0 beta2程序集

下一篇: 运行PowerShell脚本的预制环境