mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-05 20:39:38 +01:00
Added write-headline.ps1
This commit is contained in:
parent
2b4fb24678
commit
6132292e2a
32
scripts/write-headline.ps1
Normal file
32
scripts/write-headline.ps1
Normal file
@ -0,0 +1,32 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Writes text as headline
|
||||
.DESCRIPTION
|
||||
This PowerShell script writes the given text as a headline.
|
||||
.PARAMETER text
|
||||
Specifies the headline text
|
||||
.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 headline text" }
|
||||
|
||||
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
|
||||
}
|
Loading…
Reference in New Issue
Block a user