有没有办法对 Powershell cmdlet 的结果进行自动换行? [英] Is there a way to wordwrap results of a Powershell cmdlet?
问题描述
简单(可能是愚蠢的)问题.我是 Powershell 新手,主要使用它来实例化托管库,因此当我需要使用它们的成员时,我不必编写小应用程序.其中一些库很旧,并且具有带有冗长痛苦签名的方法.在使用 new-object 实例化后使用 get-member,我经常遇到如下令人沮丧的结果:
Simple (probably stupid) question. I'm a Powershell novice and am mainly using it to instantiate managed libraries so I don't have to write little apps when I need to use members from them. Some of these libraries are old and have methods with long, painful signatures. Using get-member after instantiating with new-object, I've often run into frustrating results like this:
PS> $object | get-member MethodWithLongSignature
TypeName: SomeLib.SomeObject
Name MemberType Definition
---- ---------- ----------
MethodWithLongSignature Method System.Void MethodWithLongSignature(string param1, int param2, string param3, string param4, stri....
有没有办法把get-member的结果包装起来?或者,是否有用于 get-member 的开关,它会以不换行的方式生成结果?
Is there any way to wrap the results of get-member? Alternatively, is there a switch for get-member that will produce the results in a manner that won't wrap?
推荐答案
表格结构中的输出会自动格式化以适应屏幕的宽度,如有必要,在过程中截断长值.
Output in table structures are auto-formatted to fit the width of the screen, truncating long values in the process if necessary.
将结果传送到 format-list
命令中以获得详细的垂直格式的结果.
Pipe the results into the format-list
command to get verbose, vertical formatting of the results.
PS> $object | get-member MethodWithLongSignature | format-list
这篇关于有没有办法对 Powershell cmdlet 的结果进行自动换行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!