Skip to content

Instantly share code, notes, and snippets.

@jessebarocio

jessebarocio/profile.ps1 Secret

Last active Sep 1, 2017
Embed
What would you like to do?
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
You can’t perform that action at this time.