繁体   English   中英

PowerShell:执行策略的变通办法以运行脚本

[英]PowerShell: Execution policy workarounds to run a script

有执行策略的解决方法吗?

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>

(不是我的机器。)

我正在寻找与此问题相反的问题

要以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" }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM