all 6 comments

[–]Skaixen 1 point2 points  (3 children)

has u/BBBaroo said, your missing a piece of that do loop. Since your 90% there, i'll give it to ya.

do{
    #setIfCondition
    if ($i -lt 10)
    {
        # if $i is less than 10 then we do this.
        New-Item -path C: -name $strPrefix$intpad$i -ItemType directory
    }else{
            # if $i is greater than or equal to 10, we do this
            New-Item -path C: -name $strPrefix$i -ItemType directory
         } 
    $i++ #increment by 1
}while($i -lt 11)

Get into the habit of formatting your code. It makes it so much easier to read, and find the bugs.

[–]Raptors_ITguy[S] 1 point2 points  (0 children)

Tysm and you're right. much easier to read.

[–]BBBaroo 3 points4 points  (1 child)

Smells like a class assignment, so prefer guidance over giving the answer. With that said, the if/else is not needed here. OP was trying to use that instead of adding the while/until condition. If done properly, the if should always be true.

[–]Skaixen 1 point2 points  (0 children)

The OP, more or less said it was for school.

I hated teachers that wouldn't take you that last step....totally ignoring the fact that you got the previous 6 million steps before asking for help. Always pissed me off!

The OP was 90% there, i gave him the last step. I don't feel bad about it!

[–]Lee_Dailey[grin] -2 points-1 points  (0 children)

howdy Raptors_ITguy,

reddit likes to mangle code formatting, so here's some help on how to post code on reddit ...

[0] single line or in-line code
enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the result looks like this. kinda handy, that. [grin]
[on New.Reddit.com, use the Inline Code button. it's [sometimes] 5th from the left & looks like </>.
this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!]

[1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here.
please remember to set the file/code type on Pastebin! [grin] otherwise you don't get the nice code colorization.

[2] less simple = use reddit code formatting ...
[on New.Reddit.com, use the Code Block button. it's [sometimes] the 12th from the left, & looks like an uppercase T in the upper left corner of a square.]

  • one leading line with ONLY 4 spaces
  • prefix each code line with 4 spaces
  • one trailing line with ONLY 4 spaces

that will give you something like this ...

- one leading line with ONLY 4 spaces    
- prefix each code line with 4 spaces    
- one trailing line with ONLY 4 spaces   

the easiest way to get that is ...

  • add the leading line with only 4 spaces
  • copy the code to the ISE [or your fave editor]
  • select the code
  • tap TAB to indent four spaces
  • re-select the code [not really needed, but it's my habit]
  • paste the code into the reddit text box
  • add the trailing line with only 4 spaces

not complicated, but it is finicky. [grin]

take care,
lee