![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | formatting output column width I grabbed this code from someone's website to help learn PS. Seems like it would be very handy--it recurses the home directory and lists the size of subdirectories. But the output colum for Path is truncated and displays ... so the script is nearly worthless for telling me what the path is... Any tips to get it to display the full name or change the width of the column? ============== Get-Childitem $home | Where-Object { $_.PSisContainer } | ForEach-Object { Write-Progress 'Examining Folder' ($_.FullName); $_ } | ForEach-Object { $result = '' | Select-Object Path, Count, Size; $result.path = $_.FullName; $temp = Get-Childitem $_.FullName -recurse -ea SilentlyContinue | Measure-Object length -sum -ea SilentlyContinue ; $result.count = $temp.Count; $result.Size = $temp.Sum; $result } |
My System Specs![]() |
| | #2 (permalink) |
| | Re: formatting output column width Quote: > } > > |Format-Table -AutoSize So you have: .... }|Format-Table -AutoSize Marco |
My System Specs![]() |
| | #3 (permalink) |
| | Re: formatting output column width Oh, thank you, I've now discovered the Format-* commands! "Marco Shaw [MVP]" <marco.shaw@xxxxxx_SPAMgmail.com> wrote in message news:eo4TG2elJHA.5016@xxxxxx Quote: > Quote: >> } >> >> > Try adding at the end: > |Format-Table -AutoSize > > So you have: > ... > }|Format-Table -AutoSize > > Marco |
My System Specs![]() |
| | #4 (permalink) |
| | Re: formatting output column width I've also created this small function which is really useful when you want to set the size of the buffer. For example, I recently started using PowerShell scripts in my Visual Studio post-build events and the output would get truncated at 80 chars in the output window. All I had to do to fix it was call my Set-WindowBuffer function to specify a width of 300 chars. ############################################################################## #.SYNOPSIS # Sets the width and/or height of the console's window buffer which can be # used to set a large scrollback buffer so that information isn't lost. # #.PARAMETER Width # The buffer width, in characters. If not set, the width is unchanged. # #.PARAMETER Height # The buffer height, in characters. If not set, the height is unchanged. # #.EXAMPLE # Set-WindowBuffer -Width 500 # Set-WindowBuffer -Width 500 -Height 5000 ############################################################################## function Set-WindowBuffer($Width, $Height) { $ErrorActionPreference = 'SilentlyContinue' trap { Write-Warning 'Could not set window buffer size.' } $size = $Host.UI.RawUI.BufferSize if ( $Width ) { $size.Width = $Width } if ( $Height ) { $size.Height = $Height } $Host.UI.RawUI.BufferSize = $size } Josh "Walt S" <someone@xxxxxx> wrote in message news:e1qNr7dlJHA.4696@xxxxxx Quote: > I grabbed this code from someone's website to help learn PS. > > Seems like it would be very handy--it recurses the home directory and > lists the size of subdirectories. > > But the output colum for Path is truncated and displays ... so the script > is nearly worthless for telling me what the path is... > > Any tips to get it to display the full name or change the width of the > column? > > ============== > > Get-Childitem $home | Where-Object { $_.PSisContainer } | > > ForEach-Object { > > Write-Progress 'Examining Folder' ($_.FullName); $_ } | > > ForEach-Object { $result = '' | > > Select-Object Path, Count, Size; > > $result.path = $_.FullName; > > $temp = Get-Childitem $_.FullName -recurse -ea SilentlyContinue | > > Measure-Object length -sum -ea SilentlyContinue ; > > $result.count = $temp.Count; > > $result.Size = $temp.Sum; > > $result > > } > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
Column width | General Discussion | |||
| fixed width column import | PowerShell | |||
| Change width of Excel Column | PowerShell | |||
| Details View Column Width Defaults (Registry ??) | Vista General | |||
| Details View Column Width Defaults (Registry ??) | Vista installation & setup | |||