How to switch to PowerShell 6 inside a remote PSSession

Welcome Forums General PowerShell Q&A How to switch to PowerShell 6 inside a remote PSSession

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
4 weeks, 1 day ago.

  • Author
    Posts
  • #129902

    Participant
    Points: 168
    Helping Hand
    Rank: Participant

    Hello,

    Did anybody find out how to switch from PowerShell 5.1 to PowerShell 6.x inside a PSSession?

    When I use pwsh, everything runs without error and shows me that PowerShell 6.1 is loaded.

    But when I check the $PSVersionTable variable, I am still inside PowerShell 5.1.

    Furthermore, when I try to load the WindowsCompatibility module, it says that the current version is 5.1.

    Any hint?

  • #129941

    Participant
    Points: 1,086
    Helping Hand
    Rank: Community Hero

    I can reproduce this, seems like an issue or no supported now. But I was able to do this in another way.

    Create a PowerShell endpoint using PowerShell core
    Then connect to that end point from 5.1

    # from remote server
    pwsh.exe
    New-PSSessionConfigurationFile -Path C:\Temp\ps6.pssc
    Register-PSSessionConfiguration -Path C:\Temp\ps6.pssc -Name ps6
    
    # then from client
    Enter-PSSession -ComputerName server -ConfigurationName ps6
    
  • #130377

    Participant
    Points: 168
    Helping Hand
    Rank: Participant

    Excellent!
    Works fine!
    Thanks

You must be logged in to reply to this topic.