如何在 Windows PowerShell ISE 中建立設定檔

在建立設定檔之前,您必須了解要建立何種類型的設定檔。如需詳細資訊,請參閱 about_Profiles,或在 [命令] 窗格中輸入 "get-help about_profiles" 後再按 ENTER。

若要建立新的設定檔

  1. 若要建立新的 "Current user, Windows PowerShell ISE" 設定檔,請輸入:

    if (!(test-path $profile )) 
    {new-item -type file -path $profile -force} 
    
  2. 若要建立新的 "All users, Windows PowerShell ISE" 設定檔,請輸入:

    if (!(test-path $profile.AllUsersCurrentHost)) 
    {new-item -type file -path $profile.AllUsersCurrentHost -force}
    
  3. 若要建立新的 "Current user, All Hosts" 設定檔,請輸入:

    if (!(test-path $profile.CurrentUserAllHosts)) 
    {new-item -type file -path $profile.CurrentUserAllHosts -force}
    
  4. 若要建立新的 "All users, All Hosts" 設定檔,請輸入:

    if (!(test-path $profile.AllUsersAllHosts)) 
    {new-item -type file -path $profile.AllUsersAllHosts-force} 
    

若要編輯設定檔

  1. 開啟設定檔。例如,若要開啟 Current user, Windows PowerShell ISE 設定檔,請輸入:psEdit $profile

  2. 將一些項目新增至設定檔。您可以從下列幾個範例開始進行:

    • 若要將 [輸出] 窗格的預設背景色彩變更為藍色,請在設定檔中輸入:$psISE.Options.OutputPaneBackground = 'blue' 。如需 $psISE 變數的詳細資訊,請參閱 Windows PowerShell ISE 指令碼物件模型

    • 若要將字型大小變更為 20,請在設定檔中輸入:$psISE.Options.FontSize =20

  3. 儲存設定檔。按一下 [檔案] 功能表上的 [儲存]。下一次開啟 Windows PowerShell ISE 時,將會套用上述所做的自訂。

請參閱

概念

about_Profiles
about_Signing
Set-ExecutionPolicy

其他資源

如何在 Windows PowerShell ISE 中使用設定檔
Windows PowerShell ISE 指令碼物件模型