Skip to content

Instantly share code, notes, and snippets.

@AntGut
Last active October 2, 2018 04:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AntGut/47422c8592f9f7cd785ad9d291c19a33 to your computer and use it in GitHub Desktop.
Save AntGut/47422c8592f9f7cd785ad9d291c19a33 to your computer and use it in GitHub Desktop.
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