激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

腳本之家,腳本語言編程技術及教程分享平臺!
分類導航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務器之家 - 腳本之家 - PowerShell - PowerShell因為在此系統中禁止執行腳本的解決方法

PowerShell因為在此系統中禁止執行腳本的解決方法

2020-07-07 11:50PowerShell教程網 PowerShell

今天看到國外的一篇文章可以在cmd中運行95版本的ps1格式的批處理,但經過測試默認情況下powershell支不支持執行腳本需要執行如下操作

在Powershell直接腳本時會出現:

無法加載文件 ******.ps1,因為在此系統中禁止執行腳本。有關詳細信息,請參閱 "get-help about_signing"。
所在位置 行:1 字符: 17
+ E:\Test\test.ps1 <<<<
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException

ps1的內容:

PowerShell因為在此系統中禁止執行腳本的解決方法

在powershell中執行 set-ExecutionPolicy RemoteSigned

PowerShell因為在此系統中禁止執行腳本的解決方法

下圖可以看到原來是無法運行對的,執行了上面的命令后就可以了,如下圖

PowerShell因為在此系統中禁止執行腳本的解決方法

查看“get-help about_signing”:

主題
about_signing

簡短說明
說明如何對腳本進行簽名以使其符合 Windows PowerShell 執行策略。

詳細說明
Restricted 執行策略不允許任何腳本運行。
AllSigned 和 RemoteSigned 執行策略可防止 Windows PowerShell 運行沒有數字簽名的腳本。

本主題說明如何運行所選未簽名腳本(即使在執行策略為 RemoteSigned 的情況下),還說明如何對
腳本進行簽名以便您自己使用。

有關 Windows PowerShell 執行策略的詳細信息,請參閱 about_Execution_Policy。

允許運行簽名腳本
-------------------------------
首次在計算機上啟動 Windows PowerShell 時,現用執行策略很可能是 Restricted(默認設置)。

Restricted 策略不允許任何腳本運行。

若要了解計算機上的現用執行策略,請鍵入:

get-executionpolicy

若要在本地計算機上運行您編寫的未簽名腳本和來自其他用戶的簽名腳本,請使用以下命令將計算機上的
執行策略更改為 RemoteSigned:

set-executionpolicy remotesigned

有關詳細信息,請參閱 Set-ExecutionPolicy。

 

執行“set-ExecutionPolicy RemoteSigned ”:

 

執行策略更改
執行策略可以防止您執行不信任的腳本。更改執行策略可能會使您面臨 about_Execution_Policies
幫助主題中所述的安全風險。是否要更改執行策略?
[Y] 是(Y) [N] 否(N) [S] 掛起(S) [?] 幫助 (默認值為“Y”): y

Run a CMD batch file

To run a batch script from the CMD shell, save the file as plain ASCII text with the file extension .CMD, then from the command line, enter the name of the script and press return.

C:\Batch> Demo.cmd

To run a batch file from within another batch file, use the CALL command, otherwise the first script will exit without performing any further commands.

It is also possible to run batch scripts with the old (Windows 95 style) .BAT extension, but be aware that these will set ERRORLEVEL differently.

Run a Powershell script
To run a PowerShell script from the CMD shell:

 

復制代碼 代碼如下:

C:\> powershell -file "c:\batch\demo.ps1"

 

Run a VBScript file

To run a VBScript from the CMD shell:

復制代碼 代碼如下:

C:\> cscript c:\batch\demo.vbs

 

“The method of the enterprising is to plan with audacity and execute with vigor” ~ John Christian Bovee

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 欧美精品一区自拍a毛片在线视频 | 成人黄色小视频网站 | 成人免费毛片在线观看 | 91av在线免费播放 | 美女毛片在线观看 | 成人福利在线 | 免费视频aaa | 国产午夜精品理论片a级探花 | 第一福利在线 | www.91sp| 国产剧情v888av| 他也色在线视频 | 亚洲欧美国产视频 | 欧美成人精品欧美一级乱黄 | 欧美性videofree精品 | 免费观看一区二区三区视频 | 毛片视频观看 | 国产毛片网 | 欧美在线另类 | 国产精品亚洲yourport | 法国性xxx精品hd专区 | 国产一级毛片高清 | 啪啪毛片 | 免费高潮在线国 | 538在线精品 | 九九热国产在线 | 黄色免费高清网站 | 国产在线精品一区二区三区 | 奇米影视在线 | 小视频免费在线观看 | 欧美成人福利 | 日本在线免费观看 | 黄色作爱视频 | 91快色视频 | 国产久草视频在线 | 精品一区在线视频 | 国产精品久久久久永久免费观看 | 久国产 | 看免费黄色一级片 | 免费在线观看成年人视频 | 一级黄色在线免费观看 |