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

Anyone have any ideas what I can do? Please reserve commenting about using 1.1
I can't figure out why the following wont work, any ideas?? public interface IFieldSimpleItem
I can get at the ViewData and the ViewContext but not the Model. Any
I successfully instantiated the object class but I can't figure out how to call
Any ideas where can I find a free (trial or for educational purposes) WebSphere
Any ideas of how best i can implement article revision history for a Java
Just wondering if anyone has any ideas on how we can style templates... Like
How can i achieve event handling for dynamic controls in VB6? Any ideas?
Just trying to establish whether prototype can do something like $$('#ID a:last').css('color','#111'); Any ideas
any idea how i can get the code below to produce this output? 1

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.