Last active
January 22, 2023 09:49
-
-
Save CharlieEtienne/f4753e7d2ccdad458c626a8dde4fe3da to your computer and use it in GitHub Desktop.
PowerShell Welcome Message
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
$curUser = (Get-ChildItem Env:\USERNAME).Value | |
$curComp = (Get-ChildItem Env:\COMPUTERNAME).Value | |
$pvmaj = $Host.Version.Major | |
$pvmin = $Host.Version.Minor | |
$psversion = "$pvmaj.$pvmin" | |
$identity = "$curUser@$curComp" | |
#----------------------------------------------------- | |
# WINDOW TITLE | |
#----------------------------------------------------- | |
$Host.UI.RawUI.WindowTitle = "PowerShell" | |
#----------------------------------------------------- | |
#----------------------------------------------------- | |
# CONFIG | |
# Edit following to your convenience | |
#----------------------------------------------------- | |
$line1 = "💻 Windows PowerShell" # First line | |
$line2 = "📦 Version $psversion" # Second line | |
$line3 = "👨 $identity" # Third line | |
$line4 = "🎉 Happy coding!" # Fourth line | |
$line1color = "Cyan" # First line color | |
$line2color = "White" # Second line color | |
$line3color = "Yellow" # Third line color | |
$line4color = "Green" # Fourth line color | |
$bgColor = 'Magenta' # Background Color | |
$padding = 2 # Padding | |
#----------------------------------------------------- | |
# Calculate max length based on four lines above | |
$lengths = [array] $line1.tostring().Length, $line2.tostring().Length, $line3.tostring().Length, $line4.tostring().Length | |
$size = $lengths | measure -Maximum | |
$max = $size.Maximum | |
#----------------------------------------------------- | |
# WELCOME MESSAGE | |
#----------------------------------------------------- | |
Write-Host " " | |
Write-Host ((" " * $padding), (" " * ($max[0]+1)), (" " * $padding)) -BackgroundColor $bgColor; | |
Write-Host ((" " * $padding), (" " * ($max[0]+1)), (" " * $padding)) -BackgroundColor $bgColor; | |
Write-Host ((" " * $padding), ("$line1"), (" " * ($max[0]-($line1.Length))), (" " * $padding)) -BackgroundColor $bgColor -ForegroundColor $line1color; | |
Write-Host ((" " * $padding), ("$line2"), (" " * ($max[0]-($line2.Length))), (" " * $padding)) -BackgroundColor $bgColor -ForegroundColor $line2color; | |
Write-Host ((" " * $padding), ("$line3"), (" " * ($max[0]-($line3.Length))), (" " * $padding)) -BackgroundColor $bgColor -ForegroundColor $line3color; | |
Write-Host ((" " * $padding), ("$line4"), (" " * ($max[0]-($line4.Length))), (" " * $padding)) -BackgroundColor $bgColor -ForegroundColor $line4color; | |
Write-Host ((" " * $padding), (" " * ($max[0]+1)), (" " * $padding)) -BackgroundColor $bgColor; | |
Write-Host ((" " * $padding), (" " * ($max[0]+1)), (" " * $padding)) -BackgroundColor $bgColor; | |
Write-Host " " | |
Write-Host " " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks Great! perhaps consider adding some ascii art or text in the future!