Как отобразить информацию Get-Help вне консоли - PullRequest
0 голосов
/ 13 июня 2019

Я пишу сценарий powershell, в котором мне нужно взять информацию Get-Help для файла и отобразить ее пользователю в модальном окне.Она так хорошо отображается, когда я запускаю команду из консоли:

NAME
    Format-Table

SYNOPSIS
    Formats the output as a table.


SYNTAX
    Format-Table [[-Property] <Object[]>] [-AutoSize] [-DisplayError] [-Expand {CoreOnly | EnumOnly | Both}] [-Force] [-GroupBy <Object>] [-HideTableHeaders] [-InputObject <PSObject>] [-ShowError] [-View <String>] [-Wrap] [<CommonParameters>]


DESCRIPTION
    The Format-Table cmdlet formats the output of a command as a table with the selected properties of the object in each column. The object type determines the default layout and properties that are displayed in each column, but you can use the Property 
    parameter to select the properties that you want to see.

    You can also use a hash table to add calculated properties to an object before displaying it and to specify the column headings in the table. To add a calculated property, use the Property or GroupBy parameter.


RELATED LINKS
    Online Version: http://go.microsoft.com/fwlink/?LinkId=821775
    Format-Custom 
    Format-Hex 
    Format-List 
    Format-Wide 

REMARKS
    To see the examples, type: "get-help Format-Table -examples".
    For more information, type: "get-help Format-Table -detailed".
    For technical information, type: "get-help Format-Table -full".
    For online help, type: "get-help Format-Table -online"

, но передача ее прямо во внешнее окно будет выглядеть примерно так:

@{examples=@{example=System.Management.Automation.PSObject[]}; inputTypes=@{inputType=@{type=@{name=System.Management.Automation.PSObject}; description=System.Management.Automation.PSObject[]}}; alertSet=@{alert=System.Management.Automation.PSObject[]}; syntax=@{syntaxItem=@{name=Format-Table; parameter=System.Management.Automation.PSObject[]}}; parameters=@{parameter=System.Management.Automation.PSObject[]}; details=@{description=System.Management.Automation.PSObject[]; verb=Format; noun=Table; name=Format-Table}; description=System.Management.Automation.PSObject[]; relatedLinks=@{navigationLink=System.Management.Automation.PSObject[]}; returnValues=@{returnValue=@{type=@{name=Microsoft.PowerShell.Commands.Internal.Format}; description=System.Management.Automation.PSObject[]}}; xmlns:maml=http://schemas.microsoft.com/maml/2004/10; xmlns:command=http://schemas.microsoft.com/maml/dev/command/2004/10; xmlns:dev=http://schemas.microsoft.com/maml/dev/2004/10; xmlns:MSHelp=http://msdn.microsoft.com/mshelp; Name=Format-Table; Category=Cmdlet; Synopsis=Formats the output as a table.; Component=; Role=; Functionality=; PSSnapIn=; ModuleName=Microsoft.PowerShell.Utility}

Я понимаю, что это потому, чтона самом деле это не строка, но у меня возникают проблемы с выяснением, как разобрать возвращенный MamlCommandHelpInfo, чтобы он красиво отображался за пределами консоли.Для некоторых элементов возвращаемого объекта Get-Info я могу сделать что-то вроде этого, чтобы выбрать отдельные разделы (хотя даже для вывода этого нужно больше форматирования):

$helpText = Get-Help Format-Table | select synopsis

Но для чего-то вроде раздела параметров,Я продолжаю нажимать на этот PSObject [] и повторяю циклически, я не могу получить какую-либо информацию от отдельных объектов (которые, как я предполагаю, содержат массив параметров).

Должен быть лучший способ сделать это ..какие-нибудь идеи / хитрости?Спасибо!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...