Tech Blog‎ > ‎

PowerShell - Get Current User

posted Feb 3, 2010, 1:18 PM by Victor Zakharov
Actually, there are many ways to get name of the user, which is currently logged on, including built-in .NET commands.
But let's keep our code clean and stick with native PowerShell.

To get just the user name:

"$env:username"

You might also need the domain:

"$env:userdomain"

Or both of them:

"$env:userdomain\$env:username"
Comments