I have a PowerShell script which test if two folders exists and if no folders than create new one. Problem is when I try to execute script I get "The script failed due to call depth overflow" error. Also I would like to put two conditions in one if - if folder 1 and folder 2 don't exist than create folder 1 and folder 2 - else - write folders exists. And (if it's possible) I would like to somehow check - so if folder 1 exists than create only folder 2 and write - folder 1 exists!
# Start script recording
Start-Transcript
# Variable which is path to future/existing PowerShell log folder
$ptsl = "$($env:HOMEDRIVE)\VL\Win_mult_machines"
# Variable which is path of future/existing Vagrant folder
$ptvf = "$($env:HOMEDRIVE)\VM\Win_mult_machines"
# Variable which is future/existing name of log and Vagrant folders
$lvn = "Win_mult_machines"
# Test path for script log - if path doesn't exist - create it
if (-Not (Test-Path $ptsl -PathType Container))
{
New-Item -Path "$($env:HOMEDRIVE)\VL\" -Name $lvn -ItemType Directory
}
else {
Write-Output "Folder already exists!"
}
# Test path for Vagrant box folder - if path doesn't exist - create it
if (-Not (Test-Path $ptvf -PathType Container))
{
New-Item -Path "$($env:HOMEDRIVE)VB\" -Name $lvn -ItemType Directory
}
else {
Write-Output "Folder already exists!"
}
$ptsland$ptvf). Please either include the entire script (and tell us the file name), or reduce the script to a minimal standalone script that reproduces the problem.