Created
August 14, 2020 19:22
-
-
Save BanterBoy/45d2a63ac3fd87e602597be022b887d3 to your computer and use it in GitHub Desktop.
This will display the user account and whether the session is running as admin in the WindowTitle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Display running as Administrator in WindowTitle | |
$whoami = whoami /Groups /FO CSV | ConvertFrom-Csv -Delimiter ',' | |
$MSAccount = $whoami."Group Name" | Where-Object { $_ -like 'MicrosoftAccount*' } | |
$LocalAccount = $whoami."Group Name" | Where-Object { $_ -like 'Local' } | |
#$MSAccount.Split('\')[1] | |
#$env:USERNAME | |
if ((Test-IsAdmin) -eq $true) { | |
if (($MSAccount)) { | |
$host.UI.RawUI.WindowTitle = "$($MSAccount.Split('\')[1]) - Admin Privileges" | |
} | |
else { | |
$host.UI.RawUI.WindowTitle = "$($LocalAccount) - Admin Privileges" | |
} | |
} | |
else { | |
if (($LocalAccount)) { | |
$host.UI.RawUI.WindowTitle = "$($MSAccount.Split('\')[1]) - User Privileges" | |
} | |
else { | |
$host.UI.RawUI.WindowTitle = "$($LocalAccount) - User Privileges" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment