Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplaying output in categories like Get-ChildItem
    primarykey
    data
    text
    <p>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.</p> <pre><code>PS C:\Users&gt; ".\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 </code></pre> <p>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 :)</p> <p>EDIT: Added my code. Just creating psobjects and using Write-Object to display them.</p> <pre><code>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 { } } </code></pre> <p>And <code>Format-Table -GroupBy ..</code> is not an answer. A solution would be to add a property called <code>root = $rootpath</code> and add a default view that Groups by the property <code>root</code> AND hiding it in the table so it's not displayed multiple times. The question is just.. how? :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload