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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:21:10+00:00 2026-06-17T02:21:10+00:00

Does anyone know how you can display output from a function like get-childitem when

  • 0

Does anyone know how you can display output from a function like get-childitem when it runs multiple times(array pipeline input)? I’ll try to show it With an example.

PS C:\Users> ".\Graimer", ".\Public" | Get-ChildItem


    Directory: C:\Users\Graimer


Mode                LastWriteTime     Length Name                                                            
----                -------------     ------ ----                                                            
d-r--        20.12.2012     15:59            Contacts                                                        
d-r--        06.01.2013     01:23            Desktop                                                         
d-r--        02.01.2013     17:15            Documents                                                       
d-r--        05.01.2013     16:38            Downloads                                                       
d-r--        20.12.2012     15:59            Favorites                                                       
d-r--        20.12.2012     15:59            Links                                                           
d-r--        20.12.2012     15:59            Music                                                           
d-r--        20.12.2012     15:59            Pictures                                                        
d-r--        20.12.2012     15:59            Saved Games                                                     
d-r--        20.12.2012     15:59            Searches                                                        
d-r--        20.12.2012     15:59            Videos                                                          


    Directory: C:\Users\Public


Mode                LastWriteTime     Length Name                                                            
----                -------------     ------ ----                                                            
d-r--        20.12.2012     13:57            Documents                                                       
d-r--        26.07.2012     10:13            Downloads                                                       
d-r--        26.07.2012     10:13            Music                                                           
d-r--        26.07.2012     10:13            Pictures                                                        
d-r--        26.07.2012     10:13            Videos                                                          

In my function, when I use array input and process { } Blocks, Write-output puts all the results in one table like it should. But how can I format it like this? Separate by Directory when displayed, while being stored as a standard object-array? Can’t seem to find articles on it. It doesn’t matter if it’s only possible With compiled cmdlets, I’m just looking for some clues no matter what 🙂

EDIT: Added my code. Just creating psobjects and using Write-Object to display them.

Function Get-RecurseFileCount
{
    [CmdletBinding()]
    Param
    (
        [Parameter(ValueFromPipeline=$true)]
        [String[]]$Path = "."
    )
    Begin
    {
    }
    Process
    {
        foreach ($rootpath in $Path)
        {
            Write-Verbose "Testing if path of rootdirectory exists"
            if(Test-Path $rootpath)
            {
                Write-Verbose "Getting all recursive subfolders"
                $folders = Get-ChildItem $rootpath -Recurse -ErrorAction SilentlyContinue | where {$_.PSIsContainer}

                Write-Verbose "Starting to count files in rootfolder"
                $folder = Get-Item $rootpath
                $fcount = (Get-ChildItem $rootpath -ErrorAction SilentlyContinue | where {!$_.PSIsContainer}).Count
                New-Object psobject -Property @{FolderName = $folder.Name; FolderPath = $folder.FullName; FileCount = $fcount} | Write-Output

                Write-Verbose "Starting to count files in subfolders"
                foreach($folder in $folders)
                {
                   $fname = $folder.Name
                   $fpath = $folder.FullName
                   $fcount = (Get-ChildItem $fpath -ErrorAction SilentlyContinue | where {!$_.PSIsContainer}).Count
                   New-Object psobject -Property @{FolderName = $fname; FolderPath = $fpath; FileCount = $fcount} | Write-Output
                }
                Write-Verbose "Finished with filecount"
            }
        }
    }
    End
    {
    }
}

And Format-Table -GroupBy .. is not an answer. A solution would be to add a property called root = $rootpath and add a default view that Groups by the property root AND hiding it in the table so it’s not displayed multiple times. The question is just.. how? 🙂

  • 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-17T02:21:10+00:00Added an answer on June 17, 2026 at 2:21 am

    You have to provide the GroupBy information in your view in a format.ps1xml file and update the format data to get the desired behaviour. There is no getting out of writing the ps1xml and loading it in your session.

    http://technet.microsoft.com/en-us/library/dd315396.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how we can get previous versions of z3 for linux 64?
Does anyone know how can I display an image for the browsers which don't
Hi does anyone know I can display the icon of a file that has
Does anyone know how can I display records that are not duplicated record inside
Does anyone know what is the maximum number of characters you can display in
Does anyone know if Fiddler can display the raw SOAP messages for ASMX web
Does anyone know how can I add an integer from another table to the
Does anyone know how I can display all users online in a Rails application?
Does anyone know I can make min-height work with the latest browsers? I am
Does anyone know how can I cut a string and then assign into an

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.