准备运行powershell脚本的环境

发布于 2024-10-09 10:23:03 字数 531 浏览 0 评论 0原文

我需要安排一个 powershell 脚本,在执行此操作之前,我需要通过运行一些其他 powershell 脚本来准备环境。

基本上我想运行

PowerShell.exe -noexit " & ' C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\sharepoint.ps1' "

PowerShell.exe -command " & ; ' E:\PerfCounters\Powershell\RunPerf.ps1' "

第一个语句将破坏我的环境,然后我想执行我自己的脚本。

问题是,如果我使用 -noexit 命令,下一个脚本永远不会被执行。如果我使用 -command 而不是 -noexit,这些命令似乎在不同的 powershell 实例中执行,因此我的第二个脚本出错。

我是 powershell 的新手,我尽最大努力寻找答案。任何帮助都会非常感激。谢谢!

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 Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\sharepoint.ps1' "

PowerShell.exe -command " & ' E:\PerfCounters\Powershell\RunPerf.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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

复古式 2024-10-16 10:23:03

如果您自己没有解决这个问题,或者其他人需要语法,请执行以下操作:

powershell -noprofile -command "& { & .\x.ps1; & .\z.ps1 }"

If you didn't solve this on your own, or if anyone else needs the syntax, here you go:

powershell -noprofile -command "& { & .\x.ps1; & .\z.ps1 }"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文