#Powershell WhoAmI

This is a funky function I have in my profile.ps1

Function WhoAmI([switch]$All=$False){
  If($All){$xUser = [System.Security.Principal.WindowsIdentity]::GetCurrent() }ELSE{ $xUser = ([System.Security.Principal.WindowsIdentity]::GetCurrent()).Name}
  Write-Host $xUser -Foregroundcolor Green
}

You can run:

WhoAmI

which give provide your user name -or-

WhoAmI -All

will give you extra goodness
Enjoy

Leave a Reply

%d bloggers like this: