How to Set PowerShell Color Scheme Permanently

colorspowershell

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.

Best Answer

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/

Related Question