2023-07-29 10:34:04 +02:00
|
|
|
*write-motd.ps1*
|
|
|
|
================
|
2021-11-08 21:36:42 +01:00
|
|
|
|
2022-02-10 09:01:07 +01:00
|
|
|
This PowerShell script writes the message of the day (MOTD).
|
2021-11-08 21:36:42 +01:00
|
|
|
|
2023-07-29 10:04:38 +02:00
|
|
|
Parameters
|
|
|
|
----------
|
2021-11-08 21:36:42 +01:00
|
|
|
```powershell
|
2023-07-29 10:15:44 +02:00
|
|
|
PS> ./write-motd.ps1 [<CommonParameters>]
|
2021-11-08 21:36:42 +01:00
|
|
|
|
|
|
|
[<CommonParameters>]
|
|
|
|
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
|
|
|
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
|
|
|
```
|
|
|
|
|
2023-07-29 10:04:38 +02:00
|
|
|
Example
|
|
|
|
-------
|
2021-11-08 21:36:42 +01:00
|
|
|
```powershell
|
|
|
|
PS> ./write-motd
|
|
|
|
|
|
|
|
```
|
|
|
|
|
2023-07-29 10:04:38 +02:00
|
|
|
Notes
|
|
|
|
-----
|
2022-11-17 19:46:02 +01:00
|
|
|
Author: Markus Fleschutz | License: CC0
|
2021-11-08 21:36:42 +01:00
|
|
|
|
2023-07-29 10:04:38 +02:00
|
|
|
Related Links
|
|
|
|
-------------
|
2021-11-08 21:36:42 +01:00
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
2023-07-29 10:04:38 +02:00
|
|
|
Script Content
|
|
|
|
--------------
|
2022-11-17 20:05:34 +01:00
|
|
|
```powershell
|
2022-11-17 20:02:26 +01:00
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
|
|
Writes the message of the day
|
|
|
|
.DESCRIPTION
|
|
|
|
This PowerShell script writes the message of the day (MOTD).
|
|
|
|
.EXAMPLE
|
|
|
|
PS> ./write-motd
|
|
|
|
.LINK
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
.NOTES
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
|
|
|
#>
|
|
|
|
|
|
|
|
param ()
|
|
|
|
|
|
|
|
# Retrieve information:
|
|
|
|
[system.threading.thread]::currentThread.currentCulture = [system.globalization.cultureInfo]"en-US"
|
|
|
|
$dt = [datetime]::Now
|
|
|
|
$day = $dt.ToLongDateString().split(',')[1].trim()
|
|
|
|
if ($day.EndsWith('1')) { $day += 'st' } elseif ($day.EndsWith('2')) { $day += 'nd' } elseif ($day.EndsWith('3')) { $day += 'rd' } else { $day += 'th' }
|
|
|
|
$CurrentTime = "$day, $($dt.Year) $($dt.Hour):$($dt.Minute)"
|
|
|
|
$TimeZone = (Get-TimeZone).id
|
|
|
|
|
|
|
|
$UserName = [Environment]::USERNAME
|
|
|
|
$ComputerName = [System.Net.Dns]::GetHostName().ToLower()
|
|
|
|
$OSName = "$((Get-WmiObject win32_operatingsystem).caption) Build: $([System.Environment]::OSVersion.Version.Build)"
|
|
|
|
$Kernel = "NT" # todo
|
|
|
|
$Kernel_Info = "" # todo
|
|
|
|
|
|
|
|
$BootTime = Get-WinEvent -ProviderName eventlog | Where-Object {$_.Id -eq 6005} | Select-Object TimeCreated -First 1
|
|
|
|
$TimeSpan = New-TimeSpan -Start $BootTime.TimeCreated.Date -End (Get-Date)
|
|
|
|
$Uptime = "$($TimeSpan.Days) days, $($TimeSpan.Hours) hours, $($TimeSpan.Minutes) minutes"
|
|
|
|
$PowerShellVersion = $PSVersionTable.PSVersion
|
|
|
|
$PowerShellEdition = $PSVersionTable.PSEdition
|
|
|
|
|
|
|
|
$CPU_Info = $env:PROCESSOR_IDENTIFIER + ' Rev: ' + $env:PROCESSOR_REVISION
|
|
|
|
$NumberOfProcesses = (Get-Process).Count
|
|
|
|
$CurrentLoad = "{0}%" -f $(Get-WmiObject Win32_Processor | Measure-Object -Property LoadPercentage -Average | Select-Object -ExpandProperty Average)
|
|
|
|
# $Logical_Disk = Get-CimInstance -ClassName Win32_LogicalDisk | Where-Object -Property DeviceID -eq $OS.SystemDrive
|
|
|
|
# $Processor = Get-CimInstance -ClassName Win32_Processor
|
|
|
|
# $Memory_Size = "{0}mb/{1}mb Used" -f (([math]::round($ReturnedValues.Operating_System.TotalVisibleMemorySize / 1KB)) - ([math]::round($ReturnedValues.Operating_System.FreePhysicalMemory / 1KB))), ([math]::round($ReturnedValues.Operating_System.TotalVisibleMemorySize / 1KB))
|
|
|
|
$DriveDetails = Get-PSDrive C
|
|
|
|
$DiskSize = "{0}GB free of {1}GB" -f (([math]::round($DriveDetails.Free / 1GB), ([math]::round(($DriveDetails.Used + $DriveDetails.Free) / 1GB))))
|
|
|
|
|
|
|
|
# Print results:
|
|
|
|
[Environment]::NewLine
|
|
|
|
Write-Host " ,.=:^!^!t3Z3z., " -ForegroundColor Red
|
|
|
|
Write-Host " :tt:::tt333EE3 " -ForegroundColor Red
|
|
|
|
Write-Host " Et:::ztt33EEE " -ForegroundColor Red -NoNewline
|
|
|
|
Write-Host " @Ee., .., " -ForegroundColor green -NoNewline
|
2023-07-29 09:45:37 +02:00
|
|
|
Write-Host " Time: " -ForegroundColor DarkGray -NoNewline
|
2022-11-17 20:02:26 +01:00
|
|
|
Write-Host "$CurrentTime" -ForegroundColor Cyan
|
|
|
|
Write-Host " ;tt:::tt333EE7" -ForegroundColor Red -NoNewline
|
|
|
|
Write-Host " ;EEEEEEttttt33# " -ForegroundColor Green -NoNewline
|
2023-07-29 09:45:37 +02:00
|
|
|
Write-Host " Timezone: " -ForegroundColor DarkGray -NoNewline
|
2022-11-17 20:02:26 +01:00
|
|
|
Write-Host "$TimeZone" -ForegroundColor Cyan
|
|
|
|
Write-Host " :Et:::zt333EEQ." -NoNewline -ForegroundColor Red
|
|
|
|
Write-Host " SEEEEEttttt33QL " -NoNewline -ForegroundColor Green
|
2023-07-29 09:45:37 +02:00
|
|
|
Write-Host " User: " -NoNewline -ForegroundColor DarkGray
|
2022-11-17 20:02:26 +01:00
|
|
|
Write-Host "$UserName" -ForegroundColor Cyan
|
|
|
|
Write-Host " it::::tt333EEF" -NoNewline -ForegroundColor Red
|
|
|
|
Write-Host " @EEEEEEttttt33F " -NoNewline -ForegroundColor Green
|
2023-07-29 09:45:37 +02:00
|
|
|
Write-Host " Hostname: " -NoNewline -ForegroundColor DarkGray
|
2022-11-17 20:02:26 +01:00
|
|
|
Write-Host "$ComputerName" -ForegroundColor Cyan
|
|
|
|
Write-Host " ;3=*^``````'*4EEV" -NoNewline -ForegroundColor Red
|
|
|
|
Write-Host " :EEEEEEttttt33@. " -NoNewline -ForegroundColor Green
|
2023-07-29 09:45:37 +02:00
|
|
|
Write-Host " OS: " -NoNewline -ForegroundColor DarkGray
|
2022-11-17 20:02:26 +01:00
|
|
|
Write-Host "$OSName" -ForegroundColor Cyan
|
|
|
|
Write-Host " ,.=::::it=., " -NoNewline -ForegroundColor Cyan
|
|
|
|
Write-Host "``" -NoNewline -ForegroundColor Red
|
|
|
|
Write-Host " @EEEEEEtttz33QF " -NoNewline -ForegroundColor Green
|
2023-07-29 09:45:37 +02:00
|
|
|
Write-Host " Kernel: " -NoNewline -ForegroundColor DarkGray
|
2022-11-17 20:02:26 +01:00
|
|
|
Write-Host "$Kernel " -NoNewline -ForegroundColor Cyan
|
|
|
|
Write-Host "$Kernel_Info" -ForegroundColor Cyan
|
|
|
|
Write-Host " ;::::::::zt33) " -NoNewline -ForegroundColor Cyan
|
|
|
|
Write-Host " '4EEEtttji3P* " -NoNewline -ForegroundColor Green
|
2023-07-29 09:45:37 +02:00
|
|
|
Write-Host " Uptime: " -NoNewline -ForegroundColor DarkGray
|
2022-11-17 20:02:26 +01:00
|
|
|
Write-Host "$Uptime" -ForegroundColor Cyan
|
|
|
|
Write-Host " :t::::::::tt33." -NoNewline -ForegroundColor Cyan
|
|
|
|
Write-Host ":Z3z.. " -NoNewline -ForegroundColor Yellow
|
|
|
|
Write-Host " ````" -NoNewline -ForegroundColor Green
|
|
|
|
Write-Host " ,..g. " -NoNewline -ForegroundColor Yellow
|
2023-07-29 09:45:37 +02:00
|
|
|
Write-Host " PowerShell: " -NoNewline -ForegroundColor DarkGray
|
2022-11-17 20:02:26 +01:00
|
|
|
Write-Host "$PowerShellVersion $PowerShellEdition" -ForegroundColor Cyan
|
|
|
|
Write-Host " i::::::::zt33F" -NoNewline -ForegroundColor Cyan
|
|
|
|
Write-Host " AEEEtttt::::ztF " -NoNewline -ForegroundColor Yellow
|
2023-07-29 09:45:37 +02:00
|
|
|
Write-Host " CPU: " -NoNewline -ForegroundColor DarkGray
|
2022-11-17 20:02:26 +01:00
|
|
|
Write-Host "$CPU_Info" -ForegroundColor Cyan
|
|
|
|
Write-Host " ;:::::::::t33V" -NoNewline -ForegroundColor Cyan
|
|
|
|
Write-Host " ;EEEttttt::::t3 " -NoNewline -ForegroundColor Yellow
|
2023-07-29 09:45:37 +02:00
|
|
|
Write-Host " Processes: " -NoNewline -ForegroundColor DarkGray
|
2022-11-17 20:02:26 +01:00
|
|
|
Write-Host "$NumberOfProcesses" -ForegroundColor Cyan
|
|
|
|
Write-Host " E::::::::zt33L" -NoNewline -ForegroundColor Cyan
|
|
|
|
Write-Host " @EEEtttt::::z3F " -NoNewline -ForegroundColor Yellow
|
2023-07-29 09:45:37 +02:00
|
|
|
Write-Host " Current Load: " -NoNewline -ForegroundColor DarkGray
|
2022-11-17 20:02:26 +01:00
|
|
|
Write-Host "$CurrentLoad" -ForegroundColor Cyan
|
|
|
|
Write-Host " {3=*^``````'*4E3)" -NoNewline -ForegroundColor Cyan
|
|
|
|
Write-Host " ;EEEtttt:::::tZ`` " -NoNewline -ForegroundColor Yellow
|
2023-07-29 09:45:37 +02:00
|
|
|
Write-Host " Memory: " -NoNewline -ForegroundColor DarkGray
|
2022-11-17 20:02:26 +01:00
|
|
|
Write-Host "$Memory_Size" -ForegroundColor Cyan
|
|
|
|
Write-Host " ``" -NoNewline -ForegroundColor Cyan
|
|
|
|
Write-Host " :EEEEtttt::::z7 " -NoNewline -ForegroundColor Yellow
|
2023-07-29 09:45:37 +02:00
|
|
|
Write-Host " System Volume: " -NoNewline -ForegroundColor DarkGray
|
2022-11-17 20:02:26 +01:00
|
|
|
Write-Host "$DiskSize" -ForegroundColor Cyan
|
|
|
|
Write-Host " 'VEzjt:;;z>*`` " -ForegroundColor Yellow
|
|
|
|
[Environment]::NewLine
|
|
|
|
exit 0 # success
|
2022-11-17 20:05:34 +01:00
|
|
|
```
|
2022-11-17 20:02:26 +01:00
|
|
|
|
2024-01-03 12:11:22 +01:00
|
|
|
*(generated by convert-ps2md.ps1 using the comment-based help of write-motd.ps1 as of 01/03/2024 12:10:53)*
|