- 1 year ago
if I run powershell with runas /netonly, how can I see the "netonly" user
When running PowerShell with the runas /netonly
command to execute a command as a different user, you can view the "netonly" user information using the $env:USERNAME
and $env:USERDOMAIN
environment variables within PowerShell.
Here's an example of how you can retrieve and display the "netonly" user information in PowerShell:
powershell$netonlyUsername = $env:USERNAME
$netonlyUserDomain = $env:USERDOMAIN
Write-Host "NetOnly User: $netonlyUsername"
Write-Host "NetOnly User Domain: $netonlyUserDomain"
Running the above code within your PowerShell session after using runas /netonly
will display the "netonly" user's username and domain in the console.
Note that the runas /netonly
command allows you to run applications with different credentials for accessing network resources while still using your current user account for local operations. However, the "netonly" user information is not readily accessible within the PowerShell session, as it only affects the network context for accessing remote resources.