0

I have a case where I have some Powershell code to install software that is not supported to install over WinRM/PS Remoting. Is there a way I can check in the script whether it's currently executing in the context of a WinRM or PS Remoting session? I'm aware of how to check if a returned object came from a remote execution, but not how to check whether the current context is remote or not.

2
  • Are you trying to check being in the script which is getting executed remotely ? Commented Aug 21, 2019 at 17:32
  • Yes, I want to write a check in the script to bail if it's being run over Powershell Remoting. Commented Aug 21, 2019 at 17:43

1 Answer 1

2

You can check the $PSSenderInfo automatic variable which will be null in local sessions.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.