了解如何將Windows 11和10的配置為啟用腳本執行運行PowerShell腳本。
PowerShell是最強大的Shell程序和Windows的腳本語言之一。它允許您輕鬆運行命令,自動化任務並創建腳本。最好的事情是,有大量官方和社區驅動的PowerShell腳本可以簡化Windows中的任務並自動化任務。例如,您可以自動添加應用程序,刪除比指定數量的年齡更古老的文件,顯示消息框,更改DNS設置等等。
儘管運行腳本的能力非常有用,但此功能在Windows 11和Windows 10中被默認值阻止,Windows 11 and Windows 10中的默認值都無法執行腳本。如果您不得不啟用腳本,那麼您會啟用“執行程序”,因為該腳本會啟用“執行程序”,因為該腳本執行了,因此該功能是“執行的”。錯誤。
Before You Start
You require administrative rights to turn on script execution in PowerShell on Windows 11 and Windows 10.
Enable PowerShell Script Execution in Windows 11
Open Settings by pressing the “Windows key + I“keyboard shortcut.Go to the “System“tab在側邊欄上。單擊“ 高級“或“為開發人員”選項。單擊和擴展“ powershell “下拉下拉。 is already open.With that, you have enabled script execution in PowerShell and can run scripts without restrictions.
To turn off script execution, follow the same steps as above but turn OFF the toggle in step 5.
Change Execution Policy to Enable Script Execution in PowerShell
Note: The steps below are compatible with both Windows 11 and Windows 10。
在PowerShell中,您需要將執行策略從“限制”更改為“遠程設計”以啟用腳本執行。
按下“ Windows鍵”以打開開始菜單.search for“ powerShell “。單擊“ 作為管理員“選項。 運行以下命令以下命令更改當前的執行策略。 “ enter “。執行並可以運行PowerShell腳本。
如果要驗證或檢查當前執行策略,只需運行Get-Execution-Policy命令即可。命令響應應顯示“遠程設計”。
註釋:上面的命令只能讓您運行在計算機上創建的腳本或從Internet或其他計算機下載的簽名腳本。如果您想運行未簽名的腳本,則必須將執行策略設置為“無限制”,而不是“遠程設計”。在Windows 11和10中啟用PowerShell腳本執行是如此簡單。如果您需要任何幫助,請在下面評論。我很樂意為您提供幫助。文章。