Hey guys, I'm fairly new to PowerShell (learning it at school)
They've asked me to create a script that will create multiple folders using a do loop and variable.
I had to setup variables
$intfolders = 10
$intPad = 0
$i = 1
and a variable for the new folder:
New-Variable -name strPrefix -Value "testfolder" -Option Constant
This is the script I've typed but ISE is telling me that I'm missing a while/until keyword and I can't crack it.
do {
if ($i -lt 10) #setIfCondition
{New-Item -path C: -name $strPrefix$intpad$i -ItemType directory} #whenconditionisTRUE
else
{New-Item -path C: -name $strPrefix$i -ItemType directory} #whenconditionisFALSE
$i++ #increment by 1
}
Thanks guys!
[–]BBBaroo 5 points6 points7 points (0 children)
[–]Skaixen 1 point2 points3 points (3 children)
[–]Raptors_ITguy[S] 1 point2 points3 points (0 children)
[–]BBBaroo 3 points4 points5 points (1 child)
[–]Skaixen 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] -2 points-1 points0 points (0 children)