rohabu
2/22/2018 - 8:26 AM

Count with leading zeros

Count in a for loop with a given number of digits. Digits which are not used in the actual number will be filled with leading zeros. Usefull for generating test accounts or computernames with a incrementing number of a fixed with.

for ($i=1; $i -le 100; $i++) {
    $count = $i.ToString("000000")
    Write-Host "Zeile $count"
}