[英]Is there a way to check if the current Powershell script is being executed over a WinRM/PS Remoting session?
I have a case where I have some Powershell code to install software that is not supported to install over WinRM
/ PS Remoting
. 我遇到的情况是,我有一些Powershell代码来安装不支持通过
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? 有什么方法可以检查脚本是否正在
WinRM
或PS Remoting
会话的上下文中执行? 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. 我知道如何检查返回的对象是否来自远程执行,但不知道如何检查当前上下文是否为远程。
您可以检查$PSSenderInfo
自动变量,该变量在本地会话中为空。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.