-
Notifications
You must be signed in to change notification settings - Fork 1
/
Get-PaddedCenter.ps1
44 lines (40 loc) · 1.26 KB
/
Get-PaddedCenter.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function Get-PaddedCenter
{
<#
.SYNOPSIS
Short Description
.DESCRIPTION
Detailed Description
.EXAMPLE
Get-PaddedCenter
explains how to use the command
can be multiple lines
.EXAMPLE
Get-PaddedCenter
another example
can have as many examples as you like
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory=$false, Position=0)]
[System.String[]]
$Title = 'Start',
[Parameter(Mandatory=$false, Position=1)]
[System.Int32]
$Width = 100,
[Parameter(Mandatory=$false, Position=2)]
[System.String]
$Separator = ' ',
[Parameter(Mandatory=$false, Position=3)]
[System.String]
$Pad = '='
)
[string]$Title = [string]::Join($Separator,$Title)
$PadLengthFull = ($Width - $Title.Length - $Separator.Length*2)
Write-Verbose -Message "PadLengthFull: $PadLengthFull"
$Remainder = 0 ; $PadLength = [system.math]::DivRem($PadLengthFull,2,[ref]$Remainder)
Write-Verbose -Message "PadLength: $PadLength"
Write-Verbose -Message "Remainder: $Remainder"
[string]::Join($Separator,$Pad*$PadLength,$Title,$Pad*($PadLength+$Remainder))
}