Distinguish caller in remote EndPoint

This topic contains 1 reply, has 2 voices, and was last updated by  Don Jones 4 months ago.

  • Author
  • #82385

    JC Ruiz

    I've written a Constrained Endpoint where the task to be performed is fixed, and launched from the StartupScript. No other user parameters.

    The idea is running it with an empty scriptblock, as

    Invoke-Command -ScriptBlock {} -Restofparams  

    It works perfectly...
    ... but I'd like to add an extra check in the StartScript.ps1 to avoid allowed users calling instead

    Enter-PsSession -InTheSameEndpoint

    I've found many variables, methods and objects to check the caller identity ($PSSenderInfo, $ExecutionContext,$PSSessionOption, and some calls to Get-WSManInstance)... but how can I get the original way the cmdlet was run in the client ?


  • #82867

    Don Jones

    You can't, because Remoting doesn't differentiate. Enter-PSSession is kind of a "hack," in that it implicitly runs New-PSSession, and then each time you hit Enter, it takes your local command line and implicitly runs it in an Invoke-Command against that session. It's not like SSH or Telnet where you're "interactively connected," although it's kind of faked-out to make you think you are.

    Since you have a startup script expecting input variables, the best I could think of would be to validate those. If they're empty, then you've clearly not connected appropriately.

You must be logged in to reply to this topic.