Created
November 24, 2020 16:26
-
-
Save roberttoups/fdb0b880f51ebcd10f2f40c1cfcff4d9 to your computer and use it in GitHub Desktop.
Upgraded PowerShell Profile Prompt
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
function prompt { | |
if(([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { | |
if($env:USERDNSDOMAIN) { | |
Write-Host "$($env:USERNAME)@$($env:USERDNSDOMAIN)" -NoNewline -ForegroundColor 'Red' | |
Write-Host "(ELEVATED)" -NoNewline -ForegroundColor 'White' | |
Write-Host ":" -NoNewline -ForegroundColor 'DarkGray' | |
Write-Host "[$($env:COMPUTERNAME)]" -NoNewline -ForegroundColor 'Yellow' | |
} else { | |
Write-Host "$($env:USERNAME)@$($env:COMPUTERNAME)" -NoNewline -ForegroundColor 'Red' | |
Write-Host "(ELEVATED)" -NoNewline -ForegroundColor 'White' | |
} | |
} else { | |
if($env:USERDNSDOMAIN) { | |
Write-Host "$($env:USERNAME)@$($env:USERDNSDOMAIN)" -NoNewline -ForegroundColor 'Yellow' | |
Write-Host ":" -NoNewline -ForegroundColor 'DarkGray' | |
Write-Host "[$($env:COMPUTERNAME)]" -NoNewline -ForegroundColor 'Yellow' | |
} else { | |
Write-Host "$($env:USERNAME)@$($env:COMPUTERNAME)" -NoNewline -ForegroundColor 'Yellow' | |
} | |
} | |
Write-Host ":" -NoNewline -ForegroundColor 'DarkGray' | |
Write-Host (Get-Date -Format G) -ForegroundColor 'Yellow' | |
Write-Host "[" -NoNewline -ForegroundColor Red | |
$CurrentPath = $ExecutionContext.SessionState.Path.CurrentLocation.Path | |
$CurrentPath = $CurrentPath.Replace($HOME, '~') | |
Write-Host $CurrentPath -NoNewline -ForegroundColor 'Green' | |
Write-Host "]" -ForegroundColor 'Red' | |
return "$('PS >' * ($nestedPromptLevel + 1)) " | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment