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:
| |
You might also need the domain:
| |
Or both of them:
| |