6

I've seen this question which isn't quite the same thing. I have Powershell Core 6 installed. I usually open Powershell with the shortcut Windows+X, and then I. Now I would like that shortcut to open Powershell Core 6 instead of the old Powershell 5. Is that possible?

3
  • @vssher - You should submit a detailed answer instead of a temporary comment.
    – Ramhound
    Dec 10, 2019 at 17:23
  • 1
    @vssher that's not going to work for what I want. You see, the shortcut "Windows+X" actually brings up a menu, which lots of useful stuff in it, and I don't want to override "Windows+X" to do something else.
    – Ray
    Dec 10, 2019 at 18:18
  • set the default terminal to Windows Terminal and set the default shell in Windows Terminal to PowerShell Core How to set PowerShell 7 as default and remove other versions
    – phuclv
    Sep 18, 2023 at 12:15

4 Answers 4

3

Or just use the new Windows Terminal and add whatever you choose.

Windows Terminal (Preview)

The Windows Terminal is a new, modern, fast, efficient, powerful, and productive terminal application for users of command-line tools and shells like Command Prompt, PowerShell, and WSL. Its main features include multiple tabs, Unicode and UTF-8 character support, a GPU accelerated text rendering engine, and custom themes, styles, and configurations.

This is an open source project and we welcome community participation. To participate please visit https://github.com/microsoft/terminal

Update based on comments thus far.

You cannot do what you are after natively. You have to hack the registry to change this.

Yet, why go thru all that effort, when you can just pin the pwsh shortcut to the first position on your taskbar, and then just press Win key + 1 (or where you put it up to position 9) on the taskbar.

For example, on my taskbar, I have Windows Terminal, pwsh, powershell, powershell_ISE, VSCode, PowerShellStudio in position 1,2,3,4,5,6.

enter image description here

So, pressing Win+#, starts the app. No reg hacking required and 2 keystrokes vs 3. One could even drop the pwsh one since it's included as an option in Windows Terminal if you have Windows Terminal and pswh installed. enter image description here

6
  • But can you launch the new terminal with Powershell 6 using the Windows+X, I shortcut? Feb 13, 2020 at 14:49
  • I am not getting your point here, as to what tool you are saying you are doing this from. The default response to the combination of WIn+X+I support.microsoft.com/en-us/help/12445/… on windows 10 is to open the Settings panel. Unless you've gone in and hacked stuff to add PSCore on that menu and assigned that shortcut. I have had PSCore on my system for a while, and I have a shortcut on my taskbar for all my commonly used tools with hotkeys assigned. I don't mess with that settings menu. I just use Windows Terminal for any console stuff and ISE/VSC the rest.
    – postanote
    Feb 13, 2020 at 19:25
  • Win+X opens the Quick Link menu, then I opens Powershell 5. As asked in the question, the OP and I would like this to open Powershell Core 6; opening the Terminal would do the job. Win+X N opens settings. Feb 13, 2020 at 23:41
  • Note my keystroke is combined not separate, hence the difference. You cannot do what you are after natively. You have to hack the registry to change this. Yet, why go thru all that effort, when you can just pin the pwsh shortcut to the first position on your taskbar, and then just press Win key + 1 (or where you put it up to position 9). on the taskbar, I have WinTerm, pwsh, powershell, powershell_ISE, VSCode, PowerShellStudio in position 1,2,3,4,5,6. So, pressing Win+#, starts the app. No reg hacking required.
    – postanote
    Feb 14, 2020 at 0:02
  • Yeppers, been using that for a long time, even before Win10, Yet, know the limit is 1-9, but the hotkeys for anything beyond 1-9 would still be a thing as well.
    – postanote
    Jul 3, 2020 at 19:16
1

Use this tool that allows you to edit the Win+X Menu: https://winaero.com/download-winx-menu-editor-allows-you-to-add-or-remove-winx-menu-items

Screenshot

Here, there are some groups. Add it to whatever group you like using the add a program button. And then, press Restart Explorer (NOTE: This will close all of your file explorer windows!)

2
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Dec 3, 2021 at 13:00
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review Dec 3, 2021 at 13:14
0

Another option to @vssher's suggestion would be to use ConEmu or Microsoft Terminal.
To set as the default terminal:


To configure the hotkey to launch Pwsh.exe in ConEmu:

  1. SettingsStartupTasks: Predefined tasks (command group)
  2. + icon or use ConEmu's default [Shells::PowerShell Core]
    1. Name (shows Group <#>): Powershell::Pwsh
    2. Hotkey: Select whatever you'd like
    3. Default task for new console: Default shell whenever you open ConEmu
    4. Taskbar jump lists: Adds this task to the ConEmu taskbar jumplist
    5. Default shell (Win+X):
      • Windows 10: Makes this the default in the Win+X menu
      • Windows 11: Doesn't affect Win+X menu
        • While the Win+X menu could also be manually modified in Win <11, it causes corruption in 11 (if someone knows of a way that doesn't result in corruption, please comment and I'll modify this)
    6. Task Parameters: None are needed, but can be customized
    7. Commands:
      pwsh.exe -NoExit -Command "Import-Module C:\Users\<username>\WindowsPowerShell\profile.ps1" -new_console:t:"Pwsh"
      
      • To launch as an Admin terminal, add a: before t:: -new_console:a:t:"Pwsh"
      • -Import-Module is optional, but allows customization of the prompt in profile.ps1:
        #
        
        # ===========================================================
                ##::[[--- Powershell PS1 Profile ---]]::##
        # ===========================================================
        
          # Microsoft.PowerShell_profile.ps1 || Profile.ps1:
            # %UserProfile%\Documents\WindowsPowerShell
            # $env:UserProfile\Documents\WindowsPowerShell
        
        # ================================================================
        
            # Variables
        #----------------------------------------------------------------
        # ANSI:
          $ESC                              = [char]27
        
        # Host.PrivateData:
          $PD                               = $($Host.PrivateData)
        
        # Colors: 
          $Host.UI.RawUI.BackgroundColor    = ($bckgrnd = 'Black')
          $Host.UI.RawUI.ForegroundColor    = 'Gray'
        
          $PD.ErrorForegroundColor          = 'Red'
          $PD.ErrorBackgroundColor          = $bckgrnd
        
          $PD.WarningForegroundColor        = 'Magenta'
          $PD.WarningBackgroundColor        = $bckgrnd
        
          $PD.DebugForegroundColor          = 'Yellow'
          $PD.DebugBackgroundColor          = $bckgrnd
        
          $PD.VerboseForegroundColor        = 'Green'
          $PD.VerboseBackgroundColor        = $bckgrnd
        
          $PD.ProgressForegroundColor       = 'Yellow'
          $PD.ProgressBackgroundColor       = $bckgrnd
        
        #================================================================
        
            # Functions
        #----------------------------------------------------------------
        
        # Prompt:
          Function set-prompt {
            Param (
              [Parameter(Position=0)]
              [ValidateSet("Default","Test")]
              $Action
            )
        
            switch ($Action) {
              "Default" {
                Function global:prompt {
                  if (test-path variable:/PSDebugContext) { '[DBG]: ' }
                    write-host " "
                    write-host ("$ESC[48;2;40;40;40m$ESC[38;2;170;210;0m$(Get-Location) $ESC[0m $ESC[0m")
        
                  if ( $host.UI.RawUI.WindowTitle -match "Administrator" ) {
                    $Host.UI.RawUI.ForegroundColor = 'Red'
                    $(if ($nestedpromptlevel -ge 1) {
                      write-host ('PS $$ ') -ForegroundColor Red -NoNewLine
                    } else {
                      write-host ('PS $ ') -ForegroundColor Red -NoNewLine
                    })
                  } else {
                    $(if ($nestedpromptlevel -ge 1) {
                      write-host ('PS $$ ') -ForegroundColor Blue -NoNewLine
                    } else {
                      write-host ('PS $ ') -ForegroundColor Blue -NoNewLine
                    })
                  }
        
                  return " "
                }
              }
            }
          }
        
          set-prompt Default
        
        # Relaunch as Admin:
          function Relaunch-Admin { Start-Process -Verb RunAs wt }
          Set-Alias psa Relaunch-Admin
        
  3. Save settings


To import the ConEmu.xml config I use:

  1. GitHub download button: Download raw file → Open in text editor
  2. Find/Replace <username> with the %UserProfile% folder name → Save changes
  3. Import via ConEmu Settings: WinKey+Alt+PImport...Save settings
5
-1

This is a workaround that I am currently using.

If you use PowerShell's $PROFILE, you could insert a line pwsh.exe in the beginning of the script. Any shortcuts of Windows to start PowerShell will effectively hook into PowerShell 6 indirectly as a child process of PowerShell 5.

1
  • How can that be done?  Please do not respond in comments; edit your answer to make it clearer and more complete. Feb 24, 2020 at 4:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .