How to set Powershell Color scheme permanently

9,279

Its possible that you are setting the colour properties in the wrong profile.

PowerShell actually has 6 profiles to chose from:

Current User, Current Host - console: $Home\[My ]Documents\WindowsPowerShell\Profile.ps1

Current User, All Hosts:$Home\[My ]Documents\Profile.ps1

All Users, Current Host - console: $PsHome\Microsoft.PowerShell_profile.ps1

All Users, All Hosts: $PsHome\Profile.ps1

Current user, Current Host - ISE: $Home\[My ]Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1

All users, Current Host - ISE: $PsHome\Microsoft.PowerShellISE_profile.ps1


Please try and set the profile colouring in the all users, all hosts profile to see if the settings persist. If it does, then try modifying for your various profiles as a user to get the configuration you want.

for more reading on PowerShell profiles (source for this answer) - see https://blogs.technet.microsoft.com/heyscriptingguy/2012/05/21/understanding-the-six-powershell-profiles/

Share:
9,279

Related videos on Youtube

RaceBase
Author by

RaceBase

Updated on September 18, 2022

Comments

  • RaceBase
    RaceBase almost 2 years

    With PowerShell 5.0, there are lot of customization options. Presently I have created my own color scheme. But I couldn't figure it out how to set these color options permanently.

    Set-PSReadlineOption -TokenKind Operator -ForegroundColor "Magenta"
    Set-PSReadlineOption -TokenKind Command -ForegroundColor "DarkYellow"
    Set-PSReadlineOption -TokenKind Parameter -ForegroundColor "Magenta"
    

    Now I kept these commands in Profile script, so that they will be loaded automatically, however it doesn't work in all cases when the shell is reset and if I want to load another Profile. Irrespective of profiles, the background color and other options which are available in PowerShell UI remain consistent. I want the same thing.

    How do I permanently set these color options for PowerShell Console.

  • Maximilian Burszley
    Maximilian Burszley over 5 years
    PowerShell has four profiles, not six. It has a different profile for each console host (whether this be powershell.exe, PowerGUI, ISE, VSCode, etc.)
  • Jay
    Jay over 4 years
    My color profile is not to be found in any profile.ps1 file on my entire system. I type '$profile' and I'm told my profile file is C:\Users[username]\OneDrive\Documents\WindowsPowerShell\‌​Microsoft.PowerShell‌​_profile.ps1. I go to the directory and the file isn't there. Also not visible when turning on display of hidden files in the folder options. I've set a color scheme that I want to replicate everywhere. Opening PS from explorer shows me my custom color scheme. Starting PS from the task bar does not. I can't be bothered manually duplicating the color scheme. What do?
  • Toto
    Toto over 2 years
    How is this better than accepted answer?