Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Add Char to string based on number.

$
0
0

What would be the best way to handle this?

If I wanted to insert leading characters based on a length defined by a number. I would like to use in a PowerShell Script where I can do $value.length then subtract that from a predefined number. The difference would then define how many A’s are inserted at the start of the string.

$field = "10"
$value = “FARM”
$value.lengnth returns 4
$field - $value.length is 6.
Create new string of AAAAAAFARM


Viewing all articles
Browse latest Browse all 13067

Latest Images

Trending Articles



Latest Images