<# : @echo off setlocal set "POWERSHELL_BAT_ARGS=%*" if defined POWERSHELL_BAT_ARGS set "POWERSHELL_BAT_ARGS=%POWERSHELL_BAT_ARGS:"=\"%" endlocal & powershell -NoLogo -NoProfile -Command "$_ = $input; Invoke-Expression $( '$input = $_; $_ = \"\"; $args = @( &{ $args } %POWERSHELL_BAT_ARGS% );' + [String]::Join( [char]10, $( Get-Content \"%~f0\" ) ) )" goto :EOF #> Set-Location -Path "C:\Users\Admin\Documents" $folders = 1..10 | foreach { New-Item -Name $_ -ItemType Directory } foreach ($folder in $folders) { Set-Location $folder.FullName $Subfolders = 1..10 | foreach { New-Item -Name $_ -ItemType Directory } foreach ($Subfolder in $Subfolders) { Set-Location $Subfolder.FullName 1..10 | foreach { New-Item -Name $_ -ItemType Directory } } }