Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function prompt {
- if(
- (New-Object Security.Principal.WindowsPrincipal ([Security.Principal.WindowsIdentity]::GetCurrent())
- ).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
- $IsAdmin = $true
- } else {
- $IsAdmin = $false
- }
- $UserDomain = $Env:COMPUTERNAME.ToLower()
- $UserName = $Env:USERNAME
- $CurrentPath = $Pwd.ToString()
- $CurrentPath = $CurrentPath.Replace($Env:USERPROFILE, "~")
- $Host.UI.RawUI.WindowTitle = "$Env:USERNAME@$UserDomain $CurrentPath - PowerShell"
- if ($IsAdmin) {
- $Host.UI.RawUI.WindowTitle += ' (Administrator)'
- $ForegroundColor = "Red"
- } else {
- $ForegroundColor = "DarkGray"
- }
- $CurrentDirectory = $CurrentPath.split('\')[-1]
- Write-Host "$UserName@${UserDomain}:" -ForegroundColor $ForegroundColor -NoNewline
- Write-Host $CurrentDirectory -ForegroundColor Gray -NoNewline
- Write-Host ">" -ForegroundColor $ForegroundColor -NoNewline
- return " "
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement