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>
我只是想找 stock quotes with a script. Yes, you can sort of/kind of run a script with copy/paste, but...isn't there anything nicer?
政策如下:
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" }
是否有执行策略的解决方法?
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>
我只是想找 stock quotes with a script. Yes, you can sort of/kind of run a script with copy/paste, but...isn't there anything nicer?
政策如下:
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" }