Check who you are logged in as for PowerShell

Check who you are logged in as for PowerShell

Q. How can I check who I am logged in with in PowerShell?

A. While commands such as whoami work in PowerShell there is a native option:

$me = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
$me.Identities.Name

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish