【问题标题】:Preparting environment for running a powershell script准备运行powershell脚本的环境
【发布时间】:2011-05-31 00:58:56
【问题描述】:

我需要安排一个 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 的新手,我尽我所能找到答案。这里的任何帮助将不胜感激。谢谢!

【问题讨论】:

    标签: powershell powershell-2.0


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2014-09-20
      • 2018-08-01
      • 2017-02-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-23
      • 2013-02-05
      相关资源
      最近更新 更多