簡體   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