通过VisualStudio运行时,Powershell ExecutionPolicy是错误的

Tom*_*zel 12 powershell visual-studio

我试图在VS2005项目上运行PowerShell脚本作为我的预构建的一部分.我跑了

$> powershell Set-ExecutionPolicy UnRestricted 
Run Code Online (Sandbox Code Playgroud)

从构建之前的命令行开始,我可以从命令行运行相同的脚本.但是,当脚本作为Pre-Build步骤的一部分运行时,它将失败

The execution of scripts is disabled on this system. 
Please see “get-help about_signing” for more details. 
Run Code Online (Sandbox Code Playgroud)

该脚本适用于同事的x32 XP机器,但不适用于我的x64 Windows7机器.

mjo*_*nor 35

您是否在64位和32位Powershell环境中设置了执行策略?您的64位计算机将同时拥有它们,并且每个计算机都有自己的executionpolicy设置.

  • 默认情况下,64位计算机上将运行64位.要将其设置为32位,您需要运行C:\ Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe(来源:http://kb.paessler.com/en/topic/20443-powershell-32bit -or-64-和执行政策) (5认同)