Assume I am running my machine as mydomain\myuser and I need to run some tools that require auth against someone elses domain. I do the following
runas /user:theirdomain\theiruser /netonly powershell.exe
Then in any powershell commands that I run in that powershell window I need to detect the theirdomain\theiruser that I ran with.
This was discussed here but for .net and there wasn't any solutions.
The implication was that you could run something remoted somewhere and be able to then ask that remote server what user they are using. I don't have any powershell remoting knowledge but lets assume that I have a Powershell running server somewhere that I could run a remote command against - could I use that to capture the NetOnly username?
in the meantime I think I will try to pass the username separately to the environment somehow but there must be a more elegant solution for this?
Thanks for any thoughts!