Setting Powershell colors with hex values in profile script

前端 未结 5 1462
旧时难觅i
旧时难觅i 2021-01-11 17:09

I know I can change PowerShell console colors by setting in my profile something like:

$Host.UI.RawUI.BackgroundColor = \"White\"
Clear-Host
<
5条回答
  •  感动是毒
    2021-01-11 17:36

    For anyone that may be looking to custom color the Powershell ISE here is the format.

    #Get the list of colors and hex equivalents
     [windows.media.colors] | Get-Member -Static -MemberType property | 
    ForEach-Object { 
    $psISE.Options.ConsolePaneTextBackgroundColor = `
    ([windows.media.colors]::$($_.name)).tostring() 
    “$($_.name) `t $([windows.media.colors]::$($_.name))” 
    }
    
    #Example of how to change the console color in the powershell ISE
    $psISE.Options.ConsolePaneBackgroundColor = '#FF4169E1'  #RoyalBlue
    $psISE.Options.ConsolePaneTextBackgroundColor = '#00FFFFFF'  #Transparent  
    

    Proper credit belongs to "The scripting Guy", sorry I don't have the link but the code is directly from his website.

提交回复
热议问题