how upgrade window server core powershell ?

Soheil Darvish Amiri 41 Reputation points
2023-06-10T12:02:20.6733333+00:00

hi

i install windows core 2022. and install powershell 7.3.4.

but when i use WAC powershell module to manage my server the PS version is 5.1. however i run "c:\program file\powershell\7>.\pwsh.exe" nothing happen. how can i change defualt powershell version in windows server core ?

Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Khaled Elsayed Mohamed 1,335 Reputation points
    2023-06-12T09:38:44.6833333+00:00

    Hi Soheil

    To change the default PowerShell version in Windows Server Core, you can follow these steps:

    Open a Command Prompt or PowerShell session on your Windows Server Core machine.

    Run the following command to set the default version of PowerShell:

    Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\PowerShellCore\7' -Name 'PowerShellVersion' -Value '7.3.4'
    
    

    This command updates the registry to set PowerShell version 7.3.4 as the default.

    Restart the machine to apply the changes.

    After restarting, the default version of PowerShell should be set to 7.3.4. You can verify this by opening a new PowerShell session and checking the version with the following command:

    $PSVersionTable.PSVersion
    
    

    It should display the PowerShell version as 7.3.4.

    Please note that changing the default PowerShell version affects all users on the machine. If you want to use a different PowerShell version for specific tasks or applications, you can specify the path to the desired PowerShell version executable when running commands, like you did with .\pwsh.exe in your example.

    If you encounter any issues or if the changes don't take effect, ensure that you have the correct installation of PowerShell 7.3.4 and administrative privileges to modify the registry.

    0 comments No comments

  2. Soheil Darvish Amiri 41 Reputation points
    2023-06-14T11:33:20.09+00:00

    dear @Khaled Elsayed Mohamed

    by using Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\PowerShellCore\7' -Name 'PowerShellVersion' -Value '7.3.4'

    powershell 7 did not set as a default shell. by searching more i found the following command and its work:

    Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\' -Name Shell -Value 'C:\Users\Administrator\AppData\Local\Microsoft\powershell\pwsh.exe'
    

    Screenshot 2023-06-14 145418

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.