Get endpoint name from the winRM session itself

Welcome Forums General PowerShell Q&A Get endpoint name from the winRM session itself

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

 
Participant
2 months, 2 weeks ago.

  • Author
    Posts
  • #164172

    Participant
    Topics: 1
    Replies: 5
    Points: 24
    Rank: Member

    Hi everyone,

    I have some hard time to explain what I'm looking for with words so here with code:

    When I do a remote session on a specific endpoint:

    Enter-PSSession -ComputerName mysrv -Credential $creds -ConfigurationName Jea1

    Once connected, do you know a way to get the parameter Jea1 from the session itself? I've checked the automatic variables, the session configuration but no luck or I've simply missed it.

    PS: If you don't have JEA, you can simulate with:

    Enter-PSSession -ComputerName localhost -ConfigurationName 'microsoft.powershell'

    And of course, what I'm looking for is: 'microsoft.powershell'

    Thank you in advance,

    François

  • #164205

    Senior Moderator
    Topics: 8
    Replies: 1041
    Points: 3,440
    Helping Hand
    Rank: Community Hero

    $PSSenderInfo gives you the same. Its an automatic variable and value will be available in all remote sessions.

  • #164217

    Participant
    Topics: 1
    Replies: 5
    Points: 24
    Rank: Member

    thank you for the quick answer. Sadly $PSSenderInfo (this is the first that I've tried) is useful to get the connected/runasUser information but nothing regarding the endpoint name. Here what I see on mine:

    UserInfo : System.Management.Automation.Remoting.PSPrincipal
    ClientTimeZone : System.CurrentSystemTimeZone
    ConnectionString : http://myserver:5985/wsman?PSVersion=5.1.18362.145
    ApplicationArguments : {PSVersionTable}
    ConnectedUser : myUserAccount
    RunAsUser : myGMSA

    No trace of jea1 sadly.

  • #164220

    Senior Moderator
    Topics: 8
    Replies: 1041
    Points: 3,440
    Helping Hand
    Rank: Community Hero

    see whats there in $PSSessionConfigurationName, currently I don't have another system to test, I get the values when remote into the same machine.

  • #164226

    Participant
    Topics: 1
    Replies: 5
    Points: 24
    Rank: Member

    nice try, I've missed that one but still no luck. Here the answer even if I'm connected to my JEA endpoint jea1

    http://schemas.microsoft.com/powershell/Microsoft.PowerShell

    I will continue on my side, I hope I will find the answer.

    Cheers

    François

  • #164229

    Participant
    Topics: 1
    Replies: 5
    Points: 24
    Rank: Member

    Quick update, same status, I can't find anything in variables, nothing in event log, I don't see any cmdlets that I can use to extract this info. I think I'm stuck but I really have some hard time to understand that we can't get this endpoint name once we're connected on it.

    Cheers

  • #164256

    Participant
    Topics: 2
    Replies: 999
    Points: 1,946
    Helping Hand
    Rank: Community Hero

    This is all you can get...

    Enter-PSSession -ComputerName localhost -ConfigurationName 'microsoft.powershell' -Verbose
    
    $PSSenderInfo
    $PSSessionConfigurationName
    Get-PSSessionConfiguration
    
    $PSSenderInfo | Select-Object -Property '*'
    $PSSessionConfigurationName | Select-Object -Property '*'
    Get-PSSessionConfiguration | Select-Object -Property '*'
    
    $PSSenderInfo | Get-Member -Force
    $PSSessionConfigurationName | Get-Member -Force
    Get-PSSessionConfiguration | Get-Member -Force
    
    Exit-PSSession

     

     

  • #164325

    Participant
    Topics: 1
    Replies: 5
    Points: 24
    Rank: Member

    Hi guys,

    This is a good one. After the last comment, I've decided to give it a try on my Windows 10 1903 instead of directly on my 2016 server (machine where I have a bunch of endpoints). So on my wks, I've created an constrained endpoint and once connected on it simply run $PSSenderInfo again. What was my surprise when I saw:

    UserInfo : System.Management.Automation.Remoting.PSPrincipal
    ClientTimeZone : System.CurrentSystemTimeZone
    ConnectionString : http://mymachine1:5985/wsman?PSVersion=5.1.18362.145
    ApplicationArguments : {PSVersionTable}
    ConfigurationName : Jea1
    ConnectedUser : myuser
    RunAsUser : myuser

    As you can see, on my Win10 1903 I have the correct ConfigurationName that I don't have on my 2016 server ... The only difference between the 2 is according to me the $PsVersionTable.

    Windows 2016 >  5.1.14393.3053

    Windows 1903 > 5.1.18362.145

    PS: Please accept my apologies kvprasoon.

    Do you know guys how I can update the WMF binaries? My server is fully patched according to windows update. Even after 11 years of Powershell, I never did this kind of upgrade ...

    Cheers

    François

     

  • #164397

    Participant
    Topics: 2
    Replies: 999
    Points: 1,946
    Helping Hand
    Rank: Community Hero

    You just run the normal patching, and Windows OS updates takes care of that.

    You used to have to download and install the .Net and WMF installers to get the latest version of PowerShell. Yet, that has been legacy thing since before Win10 releases. All that is part of the OS now, no  separate installs anymore.

    PS versions have always been OS version dependent to date. What's is in / on one is not necessarily available on another.

    With the release of PS OSS (v6 and beyond), well, things changed again, but oh well.

You must be logged in to reply to this topic.