0

执行策略是否有解决方法?

PS C:\Users\thufir\Desktop>
PS C:\Users\thufir\Desktop> .\stock.ps1
.\stock.ps1 : File C:\Users\thufir\Desktop\stock.ps1 cannot be loaded because running scripts is disabled on this
system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ .\stock.ps1
+ ~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
PS C:\Users\thufir\Desktop>

我只是在寻找带有脚本的股票报价。是的,你可以通过复制/粘贴来运行一个脚本,但是......没有更好的东西吗?

政策如下:

PS C:\Users\thufir\Desktop>
PS C:\Users\thufir\Desktop> Get-ExecutionPolicy -List

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
 LocalMachine       Undefined


PS C:\Users\thufir\Desktop>

(不是我的机器。)

我正在寻找这个问题的反面。

4

1 回答 1

1

要构建 Bill_Stewart 的评论,请使用以下目标创建一个快捷方式,它将允许您运行 PowerShell 脚本:

 C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -file "\\Server\Path\to\script\script.ps1"

如果您想在远程机器上运行此命令,您可以在创建上述快捷方式并将其存储在远程机器可以在网络上访问的某个位置之后执行类似的操作。

Invoke-Command -computername Computer1 -Scriptblock { Start-process "\\Server\Path\to\shortcut\shortcut.lnk" }
于 2018-02-15T22:34:19.463 回答