Error "The script failed due to call depth overflow" during execution of PowerShell script -


i have powershell script test if 2 folders exists , if no folders create new one. problem when try execute script "the script failed due call depth overflow" error. put 2 conditions in 1 if - if folder 1 , folder 2 don't exist create folder 1 , folder 2 - else - write folders exists. , (if it's possible) somehow check - if folder 1 exists create folder 2 , write - folder 1 exists!

# start script recording  start-transcript  # variable path future/existing powershell log folder  $ptsl = "$($env:homedrive)\vl\win_mult_machines"  # variable path of future/existing vagrant folder  $ptvf = "$($env:homedrive)\vm\win_mult_machines"  # variable future/existing name of log , vagrant folders  $lvn = "win_mult_machines"  # test path script log - if path doesn't exist - create  if (-not (test-path $ptsl -pathtype container))        {        new-item -path "$($env:homedrive)\vl\" -name $lvn -itemtype directory             }   else {          write-output "folder exists!"       }  # test path vagrant box folder - if path doesn't exist - create   if (-not (test-path $ptvf -pathtype container))        {        new-item -path "$($env:homedrive)vb\" -name $lvn -itemtype directory       }   else {        write-output "folder exists!"       }  

i'm not sure if causing issue, there typo in code:

   new-item -path "$($env:homedrive)vb\" -name $lvn -itemtype directory 

should be:

   new-item -path "$($env:homedrive)\vb\" -name $lvn -itemtype directory 

the error seeing suggests trying recursively beyond maximum permitted call depth (e.g new-item calling more 100 times).


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -