The PadLeft and PadRight options endeavor to increase the length of a string up to a given maximum length. Both PadLeft and PadRight take the same arguments, as follows:
PS> ''.PadRight
OverloadDefinitions
-------------------
string PadRight(int totalWidth)
string PadRight(int totalWidth, char paddingChar)
PS> ''.PadLeft
OverloadDefinitions
-------------------
string PadLeft(int totalWidth)
string PadLeft(int totalWidth, char paddingChar)
Both methods attempt to make a string up to the total width. If the string is already equal to, or longer than the total width, it won't be changed. Unless another is supplied, the padding character is a space.
The following example pads the right-hand side of strings, using . as the padding character argument:
PS> ('one', 'two', 'three').PadRight(10, '.')
one.......
two.......
three.....
Padding a string on the left, in effect, aligns the string on the right:
PS> ('one', 'two', 'three').PadLeft(10, '.')
.......one
.......two
.....three