-
-
Save jessebarocio/2cf4fb36a7d1b8d2c4edab89b8c7d900 to your computer and use it in GitHub Desktop.
Pro Tip: Use your PowerShell prompt to differentiate between regular and admin sessions
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
### | |
## Helper function to determine if current session is an admin session | |
### | |
function Test-IsAdmin { | |
return ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) | |
} | |
### | |
## Custom Prompt | |
### | |
function prompt() { | |
if(Test-IsAdmin) { | |
Write-Host -NoNewline -Fore Yellow "[ADMIN] " | |
} | |
Write-Host -NoNewline $(Get-Location) | |
Write-Host -NoNewLine '>' | |
' ' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment