Revision: 13294
Updated Code
at May 22, 2012 04:00 by ericmorin21
Updated Code
[string]$stringToPad = 1 $padChar = "X" $paddedLength = 4 $stringToPad = ($padChar * ($paddedLength - $stringToPad.Length)) + $stringToPad
Revision: 13293
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 17, 2009 17:04 by ericmorin21
Initial Code
$padChar = "X" $paddedLength = Y $stringToPad = ($padChar * ($paddedLength - $stringToPad)) + $stringToPad
Initial URL
Initial Description
For clarity, I have broken two variables out, but this could easily be a one-liner. Usage: Replace X with the character you wish to use to pad (e.g. 0 (zero)). Replace Y with an integer representing the desired TOTAL length of the string.
Initial Title
Left-padding in Powershell
Initial Tags
Initial Language
Windows PowerShell