gpt4 book ai didi

powershell - 定制功能列表的概要格式列表

转载 作者:行者123 更新时间:2023-12-02 23:25:57 26 4
gpt4 key购买 nike

我有一个Powershell脚本,其中包含代表任务的几个函数。我想用每个函数的名称和文档中提供的摘要来格式化这些函数的列表。

对于一个功能Foo:
Get-Help Foo | Format-Table -Property Name, Synopsis
我不知道如何使它具有多种功能。我在使用强大的语法时遇到了麻烦。我不知道如何声明函数列表,因为Foo, Bar是语法错误。我也尝试将函数名称列出为字符串,然后将其转换为相应的对象,但是我没有这样做。

如何打印自定义功能列表的名称和简介?

最佳答案

如您所知,Get-Help(别名help)cmdlet不会公开带有多个-name参数的参数集。但是,您可以定义一个函数数组,对其进行迭代,然后为每个函数调用Get-Help。例:

@('Get-Content', 'Get-ChildItem') | foreach { help $_ }  | Format-Table -Property Name, Synopsis

输出:
Name          Synopsis                                                          
---- --------
Get-Content Gets the content of the item at the specified location.
Get-ChildItem Gets the items and child items in one or more specified locations.

关于powershell - 定制功能列表的概要格式列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36884888/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com