If you must make sure that a given string has a uniform width, then you can use .NET methods to pad the string appropriately:
PS C:\> $mytext = 'Test'
PS C:\> $paddedText = $mytext.PadLeft(15)
PS C:\> "Here is the text: '$paddedText'"
Here is the text: ' Test'
PS C:\>
PS C:\> $paddedText = $mytext.PadRight(15)
PS C:\> "Here is the text: '$paddedText'"
Here is the text: 'Test '
|
You can even add a padding character yourself (if you do not want to pad with spaces):
PS C:\> 'Hello'.PadLeft(20, '.')
...............Hello
PS C:\> 'Hello'.PadRight(20, '_')
Hello_______________
|
http://powershell.com/cs/blogs/tips/archive/2014/03/06/padding-strings-left-and-right.aspx |