I have a for loop that needs to loop the number of times there are folders in a folder.
what i have is:
$Thickness = Get-ChildItem $PSScriptRoot |
Where-Object {$_.PSIsContainer} | #Gets the names of folders in a folder
ForEach-Object {$_.Name}
for($Counter=0;$Counter -lt $Thickness.Count;$Counter++){
if(!(Test-Path -Path "$PSScriptRoot\$Thickness[$Counter]\Previous Years")){ #Test if there is a folder called "Previous years" in each folder
new-Item -Path "$PSScriptRoot\$Thickness[$Counter]\Previous Years" -ItemType Directory #If folder "Previous Years" Does not exist, create one
}
}
What happened when i run this is that it creates a folder called all the values in the array with the Value of Counter in Brackets