Skip to content

Instantly share code, notes, and snippets.

@bearlike
Last active June 15, 2025 22:29
Show Gist options
  • Save bearlike/7875c97e3c4b7e92ef3b659c86e808b5 to your computer and use it in GitHub Desktop.
Save bearlike/7875c97e3c4b7e92ef3b659c86e808b5 to your computer and use it in GitHub Desktop.
Windows PowerShell MOTD for gigachads
#!pwsh
# Modularized MOTD script with sequential printing
#region Helper Functions
function Write-SystemInfo {
# Print a label and value with color
param(
[string]$Label,
[string]$Value,
[string]$ValueColor = "White",
[string]$LabelColor = "Cyan"
)
Write-Host "$Label : " -NoNewline -ForegroundColor $LabelColor
Write-Host $Value -ForegroundColor $ValueColor
}
function Get-HostnameInfo {
# Get computer name
return $env:COMPUTERNAME
}
function Get-NetworkInfo {
# Get first active non-virtual adapter's IPv4 address
try {
$activeAdapter = Get-NetAdapter | Where-Object { $_.Status -eq 'Up' -and $_.Virtual -eq $false } | Select-Object -First 1
if ($activeAdapter) {
$ipAddress = Get-NetIPAddress -InterfaceIndex $activeAdapter.InterfaceIndex -AddressFamily IPv4 -ErrorAction SilentlyContinue |
Where-Object { $_.IPAddress -notlike '127.*' -and $_.IPAddress -notlike '169.254.*' } |
Select-Object -First 1
if ($ipAddress) { return $ipAddress.IPAddress }
}
} catch { }
return "N/A"
}
function Get-OSAndSystemInfo {
# Get OS version, uptime, and RAM usage
try {
$os = Get-CimInstance Win32_OperatingSystem -ErrorAction Stop
$osVersion = "$($os.Caption) $($os.Version)"
$uptimeSpan = (Get-Date) - $os.LastBootUpTime
$weeks = [math]::Floor($uptimeSpan.TotalDays / 7)
$days = $uptimeSpan.Days % 7
$hours = $uptimeSpan.Hours
$minutes = $uptimeSpan.Minutes
$uptime = "$weeks weeks, $days days, $hours hours, $minutes minutes"
$totalMemGB = [math]::Round($os.TotalVisibleMemorySize / 1048576, 1)
$freeMemGB = [math]::Round($os.FreePhysicalMemory / 1048576, 1)
$usedMemGB = $totalMemGB - $freeMemGB
$ramPercent = ($usedMemGB / $totalMemGB) * 100
$ramUsage = "{0:N1}G of {1:N1}G ({2:N1}%)" -f $usedMemGB, $totalMemGB, $ramPercent
return @{
OSVersion = $osVersion
Uptime = $uptime
RAMUsage = $ramUsage
}
} catch {
return @{
OSVersion = "Unknown"
Uptime = "N/A"
RAMUsage = "N/A"
}
}
}
function Get-CPUInfo {
# Get average CPU load
try {
$cpu = Get-CimInstance Win32_Processor -ErrorAction Stop | Measure-Object -Property LoadPercentage -Average
if ($cpu.Average -ne $null) {
return $cpu.Average
}
} catch { }
return 0
}
function Get-DiskInfo {
# Get C: drive usage
try {
$disk = Get-CimInstance Win32_LogicalDisk -Filter "DeviceID='C:'" -ErrorAction Stop
if ($disk) {
$usedDiskGB = [math]::Round(($disk.Size - $disk.FreeSpace) / 1GB)
$diskPercent = (($disk.Size - $disk.FreeSpace) / $disk.Size) * 100
return "$usedDiskGB""G used ({0:N0}%)" -f $diskPercent
}
} catch { }
return "N/A"
}
function Get-GPUInfo {
# Get GPU names and memory
try {
$gpus = Get-CimInstance Win32_VideoController -Property Name,AdapterRAM -ErrorAction Stop |
Where-Object {
$_.Name -notlike '*Remote*' -and
$_.Name -notlike '*Virtual*' -and
$_.Name -notlike '*Microsoft*' -and
$_.Name -ne $null -and
$_.Name -notlike '*Basic*'
}
if ($gpus) {
$gpuList = @()
$colors = @('Yellow', 'Cyan', 'Magenta', 'Blue', 'Green')
for ($i = 0; $i -lt $gpus.Count; $i++) {
$gpu = $gpus[$i]
$cleanName = $gpu.Name -replace 'NVIDIA ', '' -replace 'AMD ', '' -replace 'Intel\(R\) ', '' -replace 'Radeon\(TM\) ', 'Radeon '
$memory = if ($gpu.AdapterRAM -and $gpu.AdapterRAM -gt 0) {
"{0:N1}G" -f ($gpu.AdapterRAM / 1GB)
} else {
"Shared"
}
$gpuList += @{
Name = $cleanName
Memory = $memory
Usage = "N/A"
Color = $colors[$i % $colors.Count]
}
}
return $gpuList
}
} catch { }
return @()
}
function Write-GPUInfo {
# Print GPU info
param([array]$gpuInfo)
Write-Host "GPU(s) : " -NoNewline -ForegroundColor Cyan
if ($gpuInfo.Count -gt 0) {
for ($i = 0; $i -lt $gpuInfo.Count; $i++) {
$gpu = $gpuInfo[$i]
$prefix = if ($i -eq 0) { "๐ŸŽฎ " } else { " " }
$separator = if ($i -lt ($gpuInfo.Count - 1)) { " | " } else { "" }
Write-Host $prefix -NoNewline
Write-Host "$($gpu.Name) " -NoNewline -ForegroundColor $gpu.Color
Write-Host "($($gpu.Memory)) " -NoNewline -ForegroundColor White
Write-Host "[$($gpu.Usage)]$separator" -ForegroundColor $gpu.Color -NoNewline
}
Write-Host ""
} else {
Write-Host "๐ŸŽฎ No GPUs detected" -ForegroundColor Red
}
}
function Start-Spinner {
# Show loading message
param(
[string]$Message = "Loading..."
)
Write-Host "$Message " -NoNewline -ForegroundColor Yellow
$script:SpinnerMessage = $Message
}
function Stop-Spinner {
# Clear spinner line
$clearLine = "`r" + (" " * ($script:SpinnerMessage.Length + 10))
Write-Host $clearLine -NoNewline
Write-Host "`r" -NoNewline
}
#endregion
#region Main Execution
Write-Host "Yo $env:USERNAME!" # Greet user
Write-Host "It's $(Get-Date -Format 'ddd MMM dd HH:mm') now"
Write-Host "โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€"
$hostname = Get-HostnameInfo
Write-SystemInfo "Hostname " $hostname
Start-Spinner "Fetching network information..."
$ip = Get-NetworkInfo
Stop-Spinner
Write-SystemInfo "Ethernet IP" $ip
Start-Spinner "Gathering system information..."
$systemInfo = Get-OSAndSystemInfo
Stop-Spinner
Write-SystemInfo "OS Version " $systemInfo.OSVersion
Write-SystemInfo "Uptime " $systemInfo.Uptime
Start-Spinner "Checking CPU load..."
$cpuLoad = Get-CPUInfo
Stop-Spinner
Write-Host "Load Average: " -NoNewline -ForegroundColor Cyan
Write-Host ("โœ”๏ธ CPU: {0:N1}%" -f $cpuLoad) -ForegroundColor Green
Write-Host "RAM Usage : " -NoNewline -ForegroundColor Cyan
Write-Host "โœ”๏ธ $($systemInfo.RAMUsage)" -ForegroundColor Green
Start-Spinner "Analyzing disk usage..."
$diskUsage = Get-DiskInfo
Stop-Spinner
Write-Host "Disk Usage : " -NoNewline -ForegroundColor Cyan
Write-Host "โœ”๏ธ $diskUsage" -ForegroundColor Green
Start-Spinner "Detecting GPU hardware..."
$gpuInfo = Get-GPUInfo
Stop-Spinner
Write-GPUInfo $gpuInfo
Start-Spinner "Finalizing system report..."
Start-Sleep -Milliseconds 500
Stop-Spinner
Write-Host "โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€" -ForegroundColor DarkGreen
Write-Host "โœฟ Quote of the day: Be careful or you'll fuck shit up โœฟ" -ForegroundColor Magenta
Write-Host "โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€" -ForegroundColor DarkGreen
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment