Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create and set a random "Session Name" in the PowerShell Console Title
Import-Module posh-git
Import-Module NameIt
function Test-Administrator {
return ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
}
##### Console Title ######
$SessionTitleName = Invoke-Generate '[Adjective][Noun]'
if (Test-Administrator) {
$SessionTitle = 'Administrator: PowerShell <' + $SessionTitleName + '>'
}
else
{
$SessionTitle = 'PowerShell <' + $SessionTitleName + '>'
}
$Host.UI.RawUI.WindowTitle = $SessionTitle
$Global:GitPromptSettings.EnableWindowTitle = "posh~git ~ <$SessionTitleName>"
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.