Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Trevor's PowerShell Prompt
function Prompt {
<#
.Notes
Author: Trevor Sullivan
Website: https://trevorsullivan.net
Twitter: https://twitter.com/pcgeek86
#>
$ATAT = @'
____==========_______
_--____ | | "" " "| \
/ )8} ^^^| 0 | = | o 0 |
</_ +-==B vvv|"" | = | ' "" "|
\_____/ |____|________|________|
(_( )\________/___( )__)
|\ \ / /\
| \ \ / /\ \
| |\ \ / / \ \
( )( ) ( \ ( )
\ / / \ \ \ \
\| |\ \ \ | |
| | )____ \ \ \ )___
( ) / / ( ) (/ /
/___\ /__/ /___\ /__/
You've discovered an AT-AT roaming Hoth!
'@
if ((Get-Random -Maximum 20) -in @(9)) {
Write-Host -ForegroundColor Cyan -Object $ATAT;
}
$Date = Get-Date
$CPU = Get-CimInstance -ClassName Win32_PerfFormattedData_Counters_ProcessorInformation
$CPUTime = $CPU.PercentProcessorTime
### NOTE: Using Get-Counter is 4x slower than using WMI performance counter classes
#$CPUTime = Get-Counter -Counter '\Processor(*)\% Processor Time'
#$CPUTime = $CPUTime.CounterSamples[-1].CookedValue
### Line 1
Write-Host -ForegroundColor Red -Object $env:USERNAME.ToLower() -NoNewline
Write-Host -ForegroundColor White -Object '@' -NoNewline
Write-Host -ForegroundColor Green -Object ($env:COMPUTERNAME.ToLower() + ' ') -NoNewline
Write-Host -ForegroundColor White -Object (Get-Location)
### Line 2: Performance Data
Write-Host -ForegroundColor Cyan -Object ('CPU: {0}' -f $CPUTime)
### Line 3
'$ '
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment