kirkmunro / formatpx Goto Github PK
View Code? Open in Web Editor NEWBetter Formatting in PowerShell
License: Apache License 2.0
Better Formatting in PowerShell
License: Apache License 2.0
FormatPx is awesome. I have some experience monkey-patching the formatting commands, and I would love to see your approach. Are you sharing the source anywhere?
Thanks!
Not sure if there is some workaround for this
PS H:\> Import-Module FormatPx -Verbose
VERBOSE: Loading module from path 'C:\Users\jcrook\Documents\PowerShell\Modules\FormatPx\1.1.3.15\FormatPx.psd1'.
VERBOSE: Populating RepositorySourceLocation property for module FormatPx.
VERBOSE: Loading module from path 'C:\Users\jcrook\Documents\PowerShell\Modules\FormatPx\1.1.3.15\FormatPx.dll'.
VERBOSE: Importing cmdlet 'Format-Custom'.
VERBOSE: Importing cmdlet 'Format-Default'.
VERBOSE: Importing cmdlet 'Format-List'.
VERBOSE: Importing cmdlet 'Format-Table'.
VERBOSE: Importing cmdlet 'Format-Wide'.
VERBOSE: Importing cmdlet 'Out-Default'.
VERBOSE: Importing cmdlet 'Out-File'.
VERBOSE: Importing cmdlet 'Out-Host'.
VERBOSE: Importing cmdlet 'Out-Printer'.
VERBOSE: Importing cmdlet 'Out-String'.
VERBOSE: Loading module from path 'C:\Users\jcrook\Documents\PowerShell\Modules\SnippetPx\1.0.6.19\SnippetPx.psd1'.
VERBOSE: Importing cmdlet 'Get-Snippet'.
VERBOSE: Importing cmdlet 'Invoke-Snippet'.
VERBOSE: Loading module from path 'C:\Users\jcrook\Documents\PowerShell\Modules\FormatPx\1.1.3.15\FormatPx.psm1'.
ObjectNotFound: The 'Out-String' command was found in the module 'FormatPx', but the module could not be loaded due to the following error: [Could not load type 'System.Management.Automation.WorkflowInfo' from assembly 'System.Management.Automation, Version=7.3.2.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.]
For more information, run 'Import-Module FormatPx'.
I did find #11503 but it seems that got reverted and broke this again
Issue reported via email from a FormatPx user:
I'm using your great FormatPx module (added to my profile), but I'm getting some errors when working with the Active Directory module. Here is an example when running Get-ADDomain:
Out-Default : Unable to cast object of type 'Microsoft.ActiveDirectory.Management.ADPropertyValueCollection' to type 'System.Collections.Generic.Stack`1[FormatPx.FormatRecord]'.
+ CategoryInfo : NotSpecified: (:) [Out-Default], InvalidCastException
+ FullyQualifiedErrorId : System.InvalidCastException,FormatPx.OutDefaultCommand
Any thoughts?
I see that the source to FormatPx.dll is not included in this repo, and unfortunately decompilers do not appear to do a good job of understanding the binary.
As including the source directly within the repo would mess up your Install-GitHubHostedModule script, would it potentially be possible to include a zip of the binary's source in a response to this issue, or as an attachment to releases?
Regards,
lordmilko
Import module have to happen without errors in Linux. I have this module path listed in PS $env:PSModulePath.
$ Import-Module FormatPx -Verbose
VERBOSE: Loading module from path '/root/XX/library/FormatPx/FormatPx.psd1'.
VERBOSE: Loading module from path '/root/XX/library/FormatPx/FormatPx.dll'.
Import-Module : Could not load type 'Microsoft.PowerShell.Commands.OutPrinterCommand' from assembly 'Microsoft.PowerShell.Commands.Utility, Version=6.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
At line:1 char:1
Version Info:
$PSVersionTable
Name Value
PSVersion 6.2.0
PSEdition Core
GitCommitId 6.2.0
OS Linux 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0โฆ}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Reported from direct email:
When using this Get-Phonetic function, __FormatData is outputted:
PS [4]: 'jOIHU56%%3##kdj?=4/' | Get-Phonetic
Input text: jOIHU56%%3##kdj?=4/
Char Phonetic __FormatData
---- -------- ------------
j juliett {FormatPx.FormatRecord}
O OSCAR {FormatPx.FormatRecord}
I INDIA {FormatPx.FormatRecord}
H HOTEL {FormatPx.FormatRecord}
U UNIFORM {FormatPx.FormatRecord}
5 five {FormatPx.FormatRecord}
6 six {FormatPx.FormatRecord}
% % {FormatPx.FormatRecord}
% % {FormatPx.FormatRecord}
3 three {FormatPx.FormatRecord}
# # {FormatPx.FormatRecord}
# # {FormatPx.FormatRecord}
k kilo {FormatPx.FormatRecord}
d delta {FormatPx.FormatRecord}
j juliett {FormatPx.FormatRecord}
? questionmark {FormatPx.FormatRecord}
= = {FormatPx.FormatRecord}
4 four {FormatPx.FormatRecord}
/ / {FormatPx.FormatRecord}
Expected or bug?
Versions 1.0.2.3 and earlier of FormatPx have a flaw that prevents several scenarios where Format-* cmdlets would be piped to Out-* cmdlets from working as expected. Since FormatPx proxies the Format-* cmdlets, and since those proxies return object data rather than format data, scripts written that would pipe format data to Out-* cmdlets (Out-String, Out-File) end up piping object data to those cmdlets instead.
Kirk,
First - Thanks for the module! I have a question, don't know if it is an issue or pilot error.
I have another module I use which imports FormatPX, I had noticed a format issue when I ran my code in a new PS window for the first time (did not have the issue on a second run in the same window). I trimmed my code to this to reproduce it.
My problem: When I do a format-table on the object (test #1), it displays as expected, after I load the FormatPX and do the same format-table (test #2), I get a format-list output instead of format-table.
==code-sample==================
$menuObj = @(
[pscustomobject]@{choice="1";labelx="x";function="Function #1";desc="Description...1"; status="x"},
[pscustomobject]@{choice="2";labelx="x";function="Function #2";desc="Description...2"; status="x"}
)
write-host "n
n Test #1 "
$menuObj |Format-Table
Import-Module FormatPX
(Get-Module FormatPX).Version
write-host "n
n Test #2 "
Execution of script output:
PS C:\Users\Administrator\OneView-shell> .\test.ps1
Test #1
choice labelx function desc status
1 x Function #1 Description...1 x
2 x Function #2 Description...2 x
Major Minor Build Revision
1 1 3 15
Test #2
choice : 1
labelx : x
function : Function #1
desc : Description...1
status : x
choice : 2
labelx : x
function : Function #2
desc : Description...2
status : x
PS C:\Users\Administrator\OneView-shell>
Additional info
PS C:\Users\Administrator\OneView-shell> $PSVersionTable
Name Value
PSVersion 4.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.17929
BuildVersion 6.3.9600.16406
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion 2.2
Thanks
-Kelly
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.