diff --git a/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DefaultFormatters/FileSystem_format_ps1xml.cs b/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DefaultFormatters/FileSystem_format_ps1xml.cs index 35845d4e781..8fde536a948 100644 --- a/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DefaultFormatters/FileSystem_format_ps1xml.cs +++ b/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DefaultFormatters/FileSystem_format_ps1xml.cs @@ -74,7 +74,7 @@ private static IEnumerable ViewsOf_FileSystemTypes(CustomC .GroupByProperty("PSParentPath", customControl: sharedControls[0]) .StartEntry(entrySelectedByType: new[] { "System.IO.FileInfo" }) .AddItemProperty(@"Name") - .AddItemScriptBlock(LengthScriptBlock) + .AddItemScriptBlock(LengthScriptBlock, label: "Length") .AddItemProperty(@"CreationTime") .AddItemProperty(@"LastWriteTime") .AddItemProperty(@"LastAccessTime") diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-List.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-List.Tests.ps1 index 247a6b49a47..c38a9b66437 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-List.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-List.Tests.ps1 @@ -149,5 +149,12 @@ Describe "Format-List DRT basic functionality" -Tags "CI" { $result | Should Match "Length : 2" $result | Should Match "Name : name3" $result | Should Match "Length : 3" - } + } + + It "Format-List with FileInfo should work" { + $null = New-Item $testdrive\test.txt -ItemType File -Value "hello" -Force + $result = Get-ChildItem -File $testdrive\test.txt | Format-List | Out-String + $result | Should Match "Name\s*:\s*test.txt" + $result | Should Match "Length\s*:\s*5" + } }