Get the currently logged in user identity via PowerShell
Sometimes we need to know exactly our identity. For instance, if we want to set an application pool's identity in IIS, then we need to know exactly how to write our current user identity. This is how.
[Security.Principal.WindowsIdentity]::GetCurrent()
The
Name
result is the exact way to specify our identity.