Skip to content

Instantly share code, notes, and snippets.

@BanterBoy
Created August 14, 2020 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BanterBoy/45d2a63ac3fd87e602597be022b887d3 to your computer and use it in GitHub Desktop.
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
# 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