Lazy Diary @ Hatena Blog

PowerShell / Java / miscellaneous things about software development, Tips & Gochas. CC BY-SA 4.0/Apache License 2.0

Size field is folded when the size > 10GB in Get-ChildItem

Context:

  • You use Powershell version 4 or earlier.
  • You have a file that the size is > 10GB.

Problem:

Size field is folded when you Get-ChildItem to the file that the size is > 10GB.

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
------       2017/03/23      1:06 1073741824 file.img
                                           0
------       2017/03/23      0:49         14 hoge.ps1

Reason:

It seems by design.

Solution:

Pass the output of Get-ChildItem to Format-Table with -Autosize option. It automatically expand width of fields to fit their content.

> Get-ChildItem | Format-Table -AutoSize

    Directory: Microsoft.PowerShell.Core\FileSystem::C:\tmp

Mode          LastWriteTime      Length Name
----          -------------      ------ ----
------ 2017/03/23      1:06 10737418240 file.img
------ 2017/03/23      0:49          14 hoge.ps1