File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <#
2+ . SYNOPSIS
3+ Writes text as headline
4+ . DESCRIPTION
5+ This PowerShell script writes the given text as a headline.
6+ . PARAMETER text
7+ Specifies the headline text
8+ . EXAMPLE
9+ PS> ./write-headline.ps1 "Hello World"
10+
11+ * Hello World *
12+ ---------------
13+ . LINK
14+ https://github.com/fleschutz/PowerShell
15+ . NOTES
16+ Author: Markus Fleschutz | License: CC0
17+ #>
18+
19+ param ([string ]$text = " " )
20+ try {
21+ if ($text -eq " " ) { $text = Read-Host " Enter the headline text" }
22+
23+ Write-Host " `n * $text *" - foregroundColor green
24+ [int ]$len = $text.Length
25+ [string ]$line = " ----"
26+ for ([int ]$i = 0 ; $i -lt $len ; $i ++ ) { $line += " -" }
27+ Write-Host " $line " - foregroundColor green
28+ exit 0 # success
29+ } catch {
30+ " ⚠️ Error in line $ ( $_.InvocationInfo.ScriptLineNumber ) : $ ( $Error [0 ]) "
31+ exit 1
32+ }
You can’t perform that action at this time.
0 commit comments