Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8017983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:00:02+00:00 2026-06-04T21:00:02+00:00

I was just trying things in PowerShell and got an error about call depth

  • 0

I was just trying things in PowerShell and got an error about call depth being set to 1000 in some test recursive function. I looked on the Internet for some information and found that this is due to error handling in PowerShell (if I got it right):

The recursion depth limit is fixed in version 1. Deep recursion was causing problems in 64-bit mode because of the way exceptions were being processed. It was causing cascading out-of-memory errors. The net result was that we hard-limited the recursion depth on all platforms to help ensure that scripts would be portable to all platforms.
– Bruce Payette, co-designer of PowerShell

I found it here.

Also I found this exception page on MSDN that states this limit is configurable (but I didn’t find anything about how to do this) – see remarks section here.

How can this limit be set?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:00:04+00:00Added an answer on June 4, 2026 at 9:00 pm
    • In PowerShell V1 the maximum call depth is 100:

    Using .NET Reflector, we can see in this snippet from the System.Management.ExecutionContext class code,

    internal int IncrementScopeDepth()
    {
        using (IDisposable disposable = tracer.TraceMethod("{0}", new object[] { this.scopeDepth }))
        {
            if (this.CurrentPipelineStopping)
            {
                throw new PipelineStoppedException();
            }
            this.scopeDepth++;
            if (this.scopeDepth > 100)
            {
                ScriptCallDepthException exceptionRecord = new
                ScriptCallDepthException(this.scopeDepth, 100);
                tracer.TraceException(exceptionRecord);
                throw exceptionRecord;
            }
            return this.scopeDepth;
        }
    }
    

    that it is not possible to modify the hardcoded 100.

    • In PowerShell V2 the maximum call depth is 1000

    Again when looking at the code, there doesn’t seem to be a way around the default maximum call depth.

    • In PowerShell V3 (CTP) there doesn’t seem to be a maximum call depth (unless you run out of resources of course). This behaviour has been described as a bug on connect, so it might change in the final version.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just trying to figure some things out in my head about getting information
I am trying to do simple thing: I just need to set some cells
Just trying to canvas some opinions here. I was wondering how people go about
I am just trying to get some things to work so I can try
Just trying to get my head around what can happen when things go wrong
I was just trying to learn the syntax of the beginner things, and how
I am just learning Jquery templates and trying different things step by step. Now
just trying to test for equality in this piece of code, but getting a
I am trying to loop through some controls in a Powershell / WPF application.
I am just trying to write a multipart parser but things getting complicated and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.