about_Run_With_PowerShell

適用於: Windows PowerShell 3.0, Windows PowerShell 4.0, Windows PowerShell 5.0

主題

about_Run_With_PowerShell

簡短描述

說明如何使用 [用 PowerShell 執行] 功能從檔案系統磁碟機執行指令碼。

詳細描述

從 Windows PowerShell® 3.0 開始,您可以使用 [用 PowerShell 執行] 功能,從檔案總管 (Windows 8 和 Windows Server 2012) 和 Windows 檔案總管 (舊版 Windows) 執行指令碼。

[用 PowerShell 執行] 功能的設計目的是用來執行不含必要參數的指令碼,且不會將輸出傳回至命令提示字元。

當您使用 [用 PowerShell 執行] 功能時,Windows PowerShell 主控台視窗 (如果有) 只會短暫出現。您無法與其互動。

若要使用 [用 PowerShell 執行] 功能:

在檔案總管 (或 Windows 檔案總管) 中,以滑鼠右鍵按一下指令碼檔案名稱,然後選取 [用 PowerShell 執行]。

[用 PowerShell 執行] 功能會啟動具有「略過」執行原則的 Windows PowerShell 工作階段、執行指令碼,然後關閉工作階段。

它會執行具有下列格式的命令:

        PowerShell.exe -File <FileName> -ExecutionPolicy Bypass

[用 PowerShell 執行] 只會針對指令碼執行所在的工作階段 (PowerShell 處理序的目前執行個體) 設定「略過」執行原則。這項功能不會變更電腦或使用者的執行原則。

只有 AllSigned 執行原則會影響 [用 PowerShell 執行] 功能。如果啟用電腦或使用者的 AllSigned 執行原則,[用 PowerShell 執行] 只會執行簽署的指令碼。任何其他執行原則都不會影響 [用 PowerShell 執行]。如需詳細資訊,請參閱 about_Execution_Policies。

疑難排解附註:[用 PowerShell 執行] 命令可能會提示您確認執行原則變更。

另請參閱

about_Execution_Policies

about_Group_Policy_Settings

about_Scripts

<執行指令碼>(https://go.microsoft.com/fwlink/?LinkId=257680)