Skip to content

Instantly share code, notes, and snippets.

@AntGut AntGut/Pad-String.ps1
Last active Oct 2, 2018

Embed
What would you like to do?
Pads an input string with spaces.
#--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==
function Pad-String ($InputString, $LeftPadding = 0, $RightPadding = 0) {
#--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==
<#
.SYNOPSIS
LeftPads input string by the specified amount and RightPads if necessary to make output string the specified total length.
.DESCRIPTION
All LeftPad/RightPad constraints are adhered to.
#>
if (-not($InputString)) {
return ""
}
return ($InputString.PadLeft($LeftPadding)).PadRight($RightPadding)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.