How can I launch powershell.exe with the "default" colours from the PowerShell shortcut? How can I launch powershell.exe with the "default" colours from the PowerShell shortcut? powershell powershell

How can I launch powershell.exe with the "default" colours from the PowerShell shortcut?


Edit your profile script (pointed to by $profile) and set the desired colors yourself:

# set regular console colors[console]::backgroundcolor = "darkmagenta"[console]::foregroundcolor = "darkyellow"# set special colors$p = $host.privatedata$p.ErrorForegroundColor    = "Red"$p.ErrorBackgroundColor    = "Black"$p.WarningForegroundColor  = "Yellow"$p.WarningBackgroundColor  = "Black"$p.DebugForegroundColor    = "Yellow"$p.DebugBackgroundColor    = "Black"$p.VerboseForegroundColor  = "Yellow"$p.VerboseBackgroundColor  = "Black"$p.ProgressForegroundColor = "Yellow"$p.ProgressBackgroundColor = "DarkCyan"# clear screenclear-host


Here's a really easy way:

1. Add .LNK to your PATHEXT variable.

Start -> run "sysdm.cpl" -> advanced -> Environment Variables

Scroll Down through system variables, double click PATHEXT

Add .LNK; as depicted below:

Path Extension

2 Copy the default "Windows Powershell.lnk"

Copy-Item "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell\Windows PowerShell.lnk" "C:\Windows\System32\powershell.lnk"

3. Typing "powershell" from a run prompt will now bring up the default console color/configuration.

You can further customize the .lnk in C:\Windows\System32 to your liking.

Please note that this will only work because you have added the .lnk to the list of acceptable extensions AND c:\windows\system32 is the first item in the search path (PATH system variable) by default.

This will not customize the console if it is launched via cmd.exe.

4. To make this work from the "Run Powershell Here" context menu, save this as a .reg file and import it:

Windows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\PowerShellHere\command]@="C:\\WINDOWS\\system32\\cmd.exe /c start powershell -NoExit \"cd '%1';(get-host).ui.rawui.windowtitle = 'Oompa Loompa'\""[HKEY_CLASSES_ROOT\Directory\shell\PowerShellHere\command]@="C:\\WINDOWS\\system32\\cmd.exe /c start powershell -NoExit \"cd '%1';(get-host).ui.rawui.windowtitle = 'Oompa Loompa'\""

I am using cmd.exe to call "start" which will launch the powershell.lnk and pass the current working directory as an argument. Doesn't seem to work from the address bar yet. I should have gone home 45mins ago, but your problem was fun to solve! :)

Bonus Points: You can thread the commands sent to Powershell. So, if you are looking to modify the Powershell console's title attribute:

\"cd '%1';(get-host).ui.rawui.windowtitle = 'Oompa Loompa'"

Simply add a semicolon between commands.

Happy shelling


I found it very useful to use concfg tool and scoop to install colors and fonts for Powershell:

  1. Install scoop:

    iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
  2. Install concfg:

    scoop install concfg
  3. Install Solarized theme:

    concfg import solarized

That's it, thanks to the authors!