如果我使用runas / netonly运行powershell,如何查看“ netonly”用户

问题描述 投票:0回答:1

假设我以mydomain \ myuser的身份运行计算机,并且需要运行一些需要对其他人的域进行身份验证的工具。我执行以下操作

runas /user:theirdomain\theiruser /netonly powershell.exe

然后在我在该Powershell窗口中运行的任何Powershell命令中,我都需要检测运行它们的domain \ theiruser。

here进行了讨论,但对于.net而言,没有任何解决方案。

含义是,您可以在某个地方运行远程的东西,然后能够询问该远程服务器他们正在使用的用户。我没有任何Powershell远程处理知识,但假设我有一个Powershell运行服务器,可以在该服务器上运行远程命令-我可以用它来捕获NetOnly用户名吗?

同时,我想我将尝试以某种方式将用户名分别传递给环境,但是对此必须有一个更优雅的解决方案?

感谢您的任何想法!

windows powershell powershell-remoting
1个回答
0
投票

我建议使用以下内容:

Invoke-Command -ScriptBlock {Get-Process} -ComputerName $computerName -Credential (Get-Credential)

或您可以使用以下内容:

Enter-PSSession -Credential (Get-Credential) -ComputerName $computerName

如果您希望使用这些凭据手动运行单个命令:

此外,请记住,获取凭据不是创建PSCredential的唯一方法,有关更多示例,请参考Microsoft documentation

© www.soinside.com 2019 - 2024. All rights reserved.