如何通过 Solution Explorer 打开的 PowerShell ISE 运行 PowerShell 脚本?

How to run the PowerShell script through PowerShell ISE which was opened by Solution Explorer?

Windows 7 x64。女士 Visual Studio 2013.

我包含了用于批量构建项目的 PowerShell 脚本。 首先,我设置了必要的执行策略(运行 具有管理员权限):

PS C:\Windows\system32> Set-ExecutionPolicy RemoteSigned

    Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic. Do you want to change the execution
policy?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Y
PS C:\Windows\system32>

我什至重装了电脑。我通过解决方案资源管理器中的上下文菜单 运行 我的脚本:

但是当我尝试 运行 它时,在 PowerShell ISE 中我收到此消息:

the execution of scripts is disabled on this system

我该如何解决?

您有两个 PowerShell,一个 32 位版本和一个 64 位版本:

C:\Windows\System32\WindowsPowerShell\v1.0
C:\Windows\SysWOW64\WindowsPowerShell\v1.0

在这两个文件夹中你会发现一个 powershell.exe 和一个 powershell_ise.exe 并且你会发现当你在一个位置更改执行策略时,它不会影响另一个版本。确保将两者都设置为所需状态,然后重试!