Who is logged in to PowerShell? Alternatives to whoami
If you are working with PowerShell, you will often face the question: "Under which user is my script running?" In other words, you want to know who is logged in. Many admins use the whoami command on the Command Prompt (cmd). However, PowerShell provides native alternatives to whoami that give you the username and domain.