【问题标题】:powershell ExecutionPolicy is not setting properly [duplicate]powershell ExecutionPolicy 设置不正确[重复]
【发布时间】:2021-06-26 03:56:03
【问题描述】:

我正在从批处理脚本运行 powershell。这是示例代码。

   powershell.exe Set-ExecutionPolicy Bypass -Force
   set logDir=C:\testfolder\
   mkdir %logDir%
   powershell.exe C:\<folder>\test.ps1 >> "%logDir%test.log"

出现错误:“test.ps1”未被识别为 cmdlet 的名称 此问题仅发生在特定 VM 上。在其他 Windows 机器上完成相同的脚本执行。 需要解决这个问题。

【问题讨论】:

    标签: windows powershell batch-file policy cmdlet


    【解决方案1】:

    每当我希望 powershell.exe 执行 ps1 文件时,我都会使用以下语法:

    powershell.exe -f "C:\<folder>\test.ps1"
    

    告诉 exe 执行文件而不是 Cmdlet。

    【讨论】:

      猜你喜欢
      • 2011-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-30
      • 1970-01-01
      • 2016-11-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多