Skip to content

Conversation

@SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Oct 18, 2018

PR Summary

The FormatData format changed in version 5.1 so during remoting a client specifies the version of PowerShell FormatData it can understand.
In the case of FileInfo (and DirectoryInfo), the format requires 5.1 so remoting must pass the -PowerShellVersion 5.1 parameter to successfully get format data. There is a bug in the logic to validate the version and it was validating the build number. So the version string 5.1 fails this check because it does not include a version number (which defaults to -1). The fix is to remove the check on the build number and simply rely on major version and minor version.

Fix #4237

PR Checklist

@adityapatwardhan adityapatwardhan merged commit 3ceb1c1 into PowerShell:master Oct 19, 2018
@SteveL-MSFT SteveL-MSFT deleted the get-formatdata branch October 20, 2018 01:33
@JoeSalmeri
Copy link

Hi Steve,

I have been anxiously awaiting this fix to test out the issues we discussed last year.

Unfortunately the problems do not appear to be fixed and things appear to be seriously broken still to the point that the results are unusable.

Run these commands

pwsh -noprofile
Get-FormatData -PowerShellVersion 6.2 -TypeName System.IO.DirectoryInfo | Export-FormatData -LiteralPath DirectoryInfo.ps1xml
Get-FormatData -PowerShellVersion 6.2 -TypeName System.IO.FileInfo      | Export-FormatData -LiteralPath FileInfo.ps1xml

If you compare DirectoryInfo.ps1xml and FileInfo.ps1xml you will find the are exactly the same, however, the output for a directory item versus a file item should not be the same as a directory does not contain a length.

Ignoring that issue, the results returned are missing lots of XML code that was previously in FileSystem.format.ps1xml.

I won't detail them all here as you can compare the results produced of Get-FormatData with the old FileSystem.format.ps1xml file to see them all, however, I will point out a few.

FileSystem.format.ps1xml created a SelectionSet named FileSystemTypes and then used that and a CustomControlName FileSystemTypes-GroupingFormat for the view definitions. Those are all missing from the "Get-FormatData" results for System.IO.DirectoryInfo / System.IO.FileInfo.

Ignore those issues, I attempted to merge my changes into the results returned from Get-FormatData and I found that my changes were not displaying so I did this simple test.

pwsh -noprofile
Get-FormatData -PowerShellVersion 6.2 -TypeName System.IO.DirectoryInfo | Export-FormatData -LiteralPath DirectoryInfo.ps1xml

Edit the DirectoryInfo.ps1xml file and make the following change:

    Look for <Label>LastWriteTime</Label> and change it to <Label>XXXXWriteTime</Label>

Now run

    Update-FormatData -PrependPath .\DirectoryInfo.ps1xml

Now run Get-ChildItem and you will see that the label still says LastWriteTime instead of XXXXWriteTime

Now run this to get what the updated formatting info looks like

    Get-FormatData -PowerShellVersion 6.2 -TypeName System.IO.DirectoryInfo | Export-FormatData -LiteralPath DirectoryInfo2.ps1xml

You will find that it does show the change, however. there is another section after it that still has the label as "LastWriteTime".

I believe all of these issues are because Get-FormatData is not returning the full and correct format data for these types.

If I run "Update-FormatData -Prepend My,FileSystem.format.ps1" which uses the modified version of the old FileSystem.format.ps1xml file that used to be included in PowerShell, then everything works correctly and it has my changes.

So we are back to the original problem.

There needs to be a way for me to obtain the format data being used (either via a file like it previously did or with Get-FormatData returning the correct formatting that is really being used).

Since PowerShell is no longer including the *.format.ps1xml files and Get-FormatData is broken and does not return the correct format data I have no way to determine what changes were made in new versions of PowerShell so that I can integrate them into my modified version.

I hope that this can be made a priority and get fixed soon.

Holler if you want any more details.

Thanks!

Joe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get-FormatData doesn't report formatting data for some types for which formatting data ships with PowerShell.

3 participants