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 1073059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:56:31+00:00 2026-05-16T20:56:31+00:00

any ideas on how I can pass the Get-PSCallStack with out having it unroll.

  • 0

any ideas on how I can pass the Get-PSCallStack with out having it unroll. It appears to be a system.object[] but from what i have read online they don’t remain intact when passed and ” unroll “. I tried placing a comma in front to prevent it but that did not work.

function Pass-Callstack ([System.Object]$arg0) {
Write-Host 'Start Pass-Callstack'
$psCallStack = $arg0
$psCallStackType = $psCallStack.GetType()
$psCallStackLength = $psCallStack.Length
$psCallStackCommand0 = $psCallStack[0].command 
$psCallStackCommand1 = $psCallStack[1].command
Write-Host $psCallStackType
Write-Host $psCallStackLength
Write-Host $psCallStackCommand0
Write-Host $psCallStackCommand1
$arg0 | gm
}

function Describe-Callstack {
Write-Host 'Start Describe-Callstack'
$psCallStack = (Get-PSCallStack)
$psCallStackType = $psCallStack.GetType()
$psCallStackLength = $psCallStack.Length
$psCallStackCommand0 = $psCallStack[0].command 
$psCallStackCommand1 = $psCallStack[1].command
Write-Host $psCallStackType
Write-Host $psCallStackLength
Write-Host $psCallStackCommand0
Write-Host $psCallStackCommand1
$psCallStack | gm
}
Describe-Callstack
Pass-Callstack (,$psCallStack)
  • 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-05-16T20:56:31+00:00Added an answer on May 16, 2026 at 8:56 pm

    When you pass an argument into a Function without piping it in there is no unrolling of collections e.g.

    function ArgShape($p)
    {
        $p.GetType().Fullname
        $p.Rank
        $p.Length
        $p[0].GetType().Fullname
    }
    
    ArgShape (Get-PSCallstack)
    
    System.Object[]
    1
    2
    System.Management.Automation.CallStackFrame
    

    Also, if you are expecting an array for the parameter to Pass-Callstack you can specify that like so:

    function Pass-Callstack([object[]]$array)
    

    Note that the use of the “System.” namespace prefix is optional. PowerShell will prepend that if it can’t find the type. Also, to specify a parameter as [object] is essentially a no-op because that is the default type. That is [object]$arg0 is the same as $arg0.

    You are also passing in $null into Pass-Callstack (albeit wrapped in a single element array). The variable $psCallStack is private to the function and not visible outside it unless you do prepend it with a modifier like $script:psCallStack. In general I don’t recommend this approach. You should output $pscallstack from Describe-Callstack like so:

    function Describe-Callstack { 
    Write-Host 'Start Describe-Callstack' 
    $psCallStack = (Get-PSCallStack) 
    $psCallStackType = $psCallStack.GetType() 
    $psCallStackLength = $psCallStack.Length 
    $psCallStackCommand0 = $psCallStack[0].command  
    $psCallStackCommand1 = $psCallStack[1].command 
    Write-Host $psCallStackType 
    Write-Host $psCallStackLength 
    Write-Host $psCallStackCommand0 
    Write-Host $psCallStackCommand1 
    $psCallStack 
    }
    

    Then assign the output of the function call to a variable:

    $cs = Describe-Callstack 
    

    And pass that into Pass-Callstack e.g.:

    Pass-Callstack $cs
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't figure out why the following wont work, any ideas?? public interface IFieldSimpleItem
Do you have any ideas how to call DoEvents from a C# DLL
Any ideas on how to disable, but not uninstall Resharper 4.x or above?
Any ideas on how to get the functionality of an attributed string on an
I have the following PHP code that I can't seem to get working. I
Any ideas on how to implement tab completion for a .NET (C#) Console Application?
Any ideas what the average user's download speed is? I'm working on a site
Any ideas how to determine the number of active threads currently running in an
Any ideas how to display a PDF file in a WPF Windows Application? I
Any ideas why this won't validate here: http://validator.w3.org/#validate_by_input It seems the form input tags

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.