locked
Sequence mask issue 01..99 RRS feed

  • Question

  • Hi all

    I am in the process of creating a server name generator and would like to add 01 to 99 on the end. However when I tried the variable equals 01..99 and then read the variable it starts at 1 not 01. Is there a way to do this?

    $NumSeq = 01..99
    many thanks


    • Edited by ktitchard Tuesday, January 9, 2018 10:40 AM
    Tuesday, January 9, 2018 10:39 AM

All replies

  • 1..99 | %{'TEST{0:D2}' -f $_}

    \_(ツ)_/

    • Proposed as answer by BOfH-666 Tuesday, January 9, 2018 11:53 AM
    Tuesday, January 9, 2018 10:49 AM
  • $NumSeq = 1..99
    
    foreach ($number in $NumSeq){
        "{0:D2}" -f $number}
    }
    This should do what you want :)

    Tuesday, January 9, 2018 11:03 AM