PowerShell/scripts/write-headline.ps1
2024-04-21 17:23:21 +02:00

33 lines
748 B
PowerShell

<#
.SYNOPSIS
Writes a headline
.DESCRIPTION
This PowerShell script writes the given text as a headline.
.PARAMETER text
Specifies the text to write
.EXAMPLE
PS> ./write-headline.ps1 "Hello World"
* Hello World *
---------------
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([string]$text = "")
try {
if ($text -eq "") { $text = Read-Host "Enter the text to write" }
Write-Host "`n* $text *" -foregroundColor green
[int]$len = $text.Length
[string]$line = "----"
for ([int]$i = 0; $i -lt $len; $i++) { $line += "-" }
Write-Host "$line" -foregroundColor green
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}