Pro Tip: Use your PowerShell prompt to differentiate between regular and admin sessions
### | |
## 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