I'm trying to get a list of all the directories and files on an external hard drive, with one fully-qualified directory/file path per line. I'm using PowerShell on Windows 10 to achieve this. This is the PowerShell command I'm using:

Get-ChildItem 'E:\' -Force -Recurse | Select-Object FullName | Out-File -Encoding utf8 "C:\Users\Me\Desktop\listing.txt" -width 300

However, some paths are being truncated in my output. In fact, over 10,000 lines are truncated. Here is an example of one line in my listing.txt PowerShell output file:

E:\Sort\Tech Stuff\2006-2007 CompanyLtd\fsie01-Engineering-Users-User1\Reference\LCID & Language Group by Language\Configuring and Using International Features of Windows Windows 2000 - List of Locale I...

When I browse to this directory in File Explorer (E:\Sort\Tech Stuff\2006-2007 CompanyLtd\fsie01-Engineering-Users-User1\Reference\LCID & Language Group by Language), the file there is called 'Configuring and Using International Features of Windows Windows 2000 - List of Locale IDs and Language Groups.url'. The path of this file is 228 characters long if I haven't miscounted, which should be within acceptable limits.

What am I doing wrong that is truncating the paths in my PowerShell output?


Pipe output to Format-Table commandlet, e.g. as follows:

Get-ChildItem 'E:\' -Force -Recurse | Select-Object FullName | Format-Table -AutoSize


(Get-ChildItem 'E:\' -Force -Recurse).FullName | Format-Table -AutoSize

Note that -Width parameter of Out-File cmdlet specifies the number of characters in each line of output. Any additional characters are truncated, not wrapped. However, -Width 300 should suffice in this case.

| improve this answer | |
  • Thanks - that seems to allow me to get the output I want. However, there's still no explanation as to what was wrong with my initial command, which looks like it should do what I want. Any idea? It's not intuitive that paths would be (apparently arbitrarily) truncated at ~205 characters unless one uses a format-table command. – osullic Mar 7 '16 at 13:18
  • 2
    For me Format-Table -AutoSize didn't help and strings were truncated anyway, whilst -width 300 did – Suncatcher May 29 '18 at 9:53
  • I had to use Format-Table -Wrap -Autosize for my case; was still getting truncated column values in multiple columns of output even after using Format-Table -Autosize – TylerH Sep 25 at 14:34

for me it works best with piping to export-csv



GCI 'E:\' -Recurse | Select FullName | Export-CSV Files.csv

without double quotes:

Add-Content -Path Files.txt -Value (GCI 'E:\' -Recurse).FullName
| improve this answer | |
  • That works, but each line gets enclosed in double quotes. So you'll have to deal with that if you don't want them. – Charles Burge Jan 29 '18 at 23:24
  • @CharlesBurge I think it depends on the culture and white space. But see my edit for a workaround. – Falco Alexander Feb 1 '18 at 10:13
  • @CharlesBurge To get ride of double quotes, just use -UseQuotes Never in the Export-CSV command. – frogcoder Aug 20 '19 at 4:30

When the returned values are strings you can pipe to out-string with width.

Get-ChildItem 'E:\' -Force -Recurse | Select-Object FullName | Out-String -Width 300 | Out-File -Encoding utf8 "C:\Users\Me\Desktop\listing.txt"

When values are in a collection/array the output is controlled by $FormatEnumerationLimit Setting it to -1 means unlimited.

Read more here Viewing Truncated PowerShell Output

I know this is an old post, but I found it before the answer I was looking for. So thought I would share my findings.

| improve this answer | |

You need to mash the answers from andreaswbj & josefz together to do what I think you are trying to do.

PS:\> $FormatEnumerationLimit = -1   
PS:\> $Console = $Host.UI.RawUI 
PS:\> $Buffer = $Console.BufferSize  
PS:\> $Buffer.Width = '4096'
PS:\> $Console.BufferSize = $Buffer 
PS:\> $Var = [PsCustomObject]@{Stdout = $("*"*1024)} 
PS:\> $Var



| improve this answer | |

I would use ConvertTo-Csv (just the same as Export-Csv but does not send to file) as you can easily continue to manipulate the results as required.

gci 'C:\Program Files\'

gci 'C:\Program Files\' | Select Mode,LastWriteTime,Length,Name | ConvertTo-Csv

This now guarantees that you have strings (not objects!) and that none of the data has been truncated, so you can continue to use any other string manipulations that you want:

gci 'C:\Program Files\' | Select Name | ConvertTo-Csv | Select-String "Win"

(gci 'C:\Program Files\' | Select Name | ConvertTo-Csv) -Replace """", ""

Second one gets rid of the " characters added by CSV encoding.


The <verb>-Csv Cmdlets will output all Property types (AliasProperty, NoteProperty, Property, ScriptProperty, etc). You can easily check that with:

gci 'C:\Program Files\' | Get-Member *Property

Also recommend using the -No (-NoTypeInformation) switch to get rid of the #TYPE Selected.System.IO.DirectoryInfo that is at the top of all outputs.

You always guarantee that you are working with non-truncated values with this method. With this I can usually organise the information that I need before throwing out to a file or screen.

| improve this answer | |

It will only work if the output is tableview. If the output is listview it's not going to work.

Get-ChildItem 'E:\' -Force -Recurse | Select-Object FullName | Format-Table -AutoSize

Read More Here: Fix Powershell Truncated Output

| improve this answer | |
  • This appears to just be the exact same solution as the accepted solution (from 4 years ago). Please be sure to read existing answers before posting a new one to ensure you avoid duplicate of content. – TylerH Sep 25 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.