mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-22 07:53:21 +01:00
33 lines
748 B
PowerShell
Executable File
33 lines
748 B
PowerShell
Executable File
<#
|
|
.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
|
|
} |