#requires -version 2.0 #This is not meant to be a script to run as is. You'll need to copy #and paste the code you want to keep into your own PowerShell projects. #Define an array of pithy sayings and slogans. #This works best when they are all about the same length #we'll create as a globally scoped variable $global:slogans=@( "PowerShell Rocks!", "Energize!!", "To Shell and Back", "I am the Shell", "PowerShell to the People", "Powered by PS", "PowerShell Rulez!", "PowerShell Fanboy" ) #now define a new prompt function Function Prompt { #reference the global $slogans array defined and #get a random element. "$($global:slogans | Get-Random) $(Get-Location) > " } #VARIATIONS Function Prompt { #get length of longest slogan and pad accordingly #get the longest slogan length $l=($slogans | sort length)[-1].length #pad with the . character "$(($global:slogans | get-random).Padright($l+1,"."))$(Get-Location) > " } #ADD A LITTLE COLOR Function Prompt { #get the longest slogan length $l=($slogans | sort length)[-1].length #pad with the . character Write-Host "$(($global:slogans | get-random).Padright($l+1,"."))" -foregroundcolor CYAN -NoNewLine Write-host "$(Get-Location)" -NoNewline #the function has to return something Write "> " } #SPEAK UP! #create a global Voice object in your profile $global:Voice=New-Object -ComObject SAPI.SPVoice Function Prompt { #get the longest slogan length $l=($slogans | sort length)[-1].length #get a slogan $text=$global:slogans | Get-Random #pad with spaces Write-Host "$($text.Padright($l+1," "))" -foregroundcolor CYAN -NoNewLine Write-host "$(Get-Location)" -NoNewline #the function has to return something Write "> " #speak it $global:voice.speak($text) | Out-Null }