Skip to content

Instantly share code, notes, and snippets.

@jessebarocio
Last active September 1, 2017 03:40
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 jessebarocio/2cf4fb36a7d1b8d2c4edab89b8c7d900 to your computer and use it in GitHub Desktop.
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
###
## 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