KirkMunro / FormatPx

Better Formatting in PowerShell
Apache License 2.0
73 stars 5 forks source link

FormatPx 1.0.3.4 does not work properly on PowerShell 5.0 #5

Closed KirkMunro closed 9 years ago

KirkMunro commented 9 years ago

This was reported to me via email:

I'm loading FormatPx in my profile, and I believe I`m running the latest version:

PS [2]: get-module ModuleType Version Name ExportedCommands


Script 1.0.3.4 FormatPx

The following seems to fail:

Format-Table : Failed to find internal PSNoteProperty field. At C:\Users\username\Documents\WindowsPowerShell\profile.ps1:118 char:38

KirkMunro commented 9 years ago

In PowerShell 3.0 and 4.0, there is an internal isHidden field on PSNoteProperty objects that you can set to hide a note property. For these versions, you must use the field because there is no set accessor on the IsHidden internal property. In PowerShell 5.0 and later, that field no longer exists, and a set accessor has been added to the IsHidden internal property. Since FormatPx depends on being able to hide note properties, this caused an error in PowerShell 5.0.

This issue has been resolved and the fix is included in FormatPx 1.0.4.5, which was released today. The solution was to perform an additional check for the IsHidden property if the isHidden field is not discoverable, allowing this logic to work on PowerShell 3, 4, and 5.