community.windows.win_psmodule_info 模块 – 收集有关 PowerShell 模块的信息

注意

此模块是 community.windows 集合 (版本 2.3.0) 的一部分。

如果您使用的是 ansible 包,则可能已安装此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.windows。您需要其他要求才能使用此模块,有关详细信息,请参阅 要求

要在剧本中使用它,请指定:community.windows.win_psmodule_info

概要

  • 收集有关 PowerShell 模块的信息,包括来自 PowerShellGet 的信息。

要求

以下是执行此模块的主机所需的条件。

  • PowerShellGet 模块

参数

参数

注释

name

字符串

要检索的模块名称。

支持 Get-Module 支持的任何通配符模式。

如果省略,则返回所有模块。

默认值: "*"

repository

字符串

模块安装所在的 PSRepository 名称。

这充当对基于 *name* 选项返回的模块的过滤器。

如果设置此选项,则不会返回未从存储库安装的模块。

仅返回从已注册的存储库安装的模块。

如果模块安装后使用新的 SourceLocation 重新注册了存储库,则此项将不匹配。

另请参阅

另请参阅

community.windows.win_psrepository_info

收集有关 PSRepositories 的信息。

community.windows.win_psscript_info

收集有关已安装的 PowerShell 脚本的信息。

示例

- name: Get info about all modules on the system
  community.windows.win_psmodule_info:

- name: Get info about the ScheduledTasks module
  community.windows.win_psmodule_info:
    name: ScheduledTasks

- name: Get info about networking modules
  community.windows.win_psmodule_info:
    name: Net*

- name: Get info about all modules installed from the PSGallery repository
  community.windows.win_psmodule_info:
    repository: PSGallery
  register: gallery_modules

- name: Update all modules retrieved from above example
  community.windows.win_psmodule:
    name: "{{ item }}"
    state: latest
  loop: "{{ gallery_modules.modules | map(attribute=name) }}"

- name: Get info about all modules on the system
  community.windows.win_psmodule_info:
  register: all_modules

- name: Find modules installed from a repository that isn't registered now
  set_fact:
    missing_repository_modules: "{{
      all_modules
      | json_query('modules[?repository!=null && repository==repository_source_location].{name: name, version: version, repository: repository}')
      | list
    }}"

- debug:
    var: missing_repository_modules

返回值

此处记录了常见的返回值 此处,以下是此模块独有的字段

描述

modules

列表 / 元素=字典

模块列表(如果没有,则为空列表)。

已返回:始终

access_mode

字符串

模块的访问模式。请参阅 https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.moduleaccessmode

已返回:成功

示例: "ReadWrite"

author

字符串

模块的作者。

已返回:成功

示例: "Warren Frame"

clr_version

字符串

模块的 CLR 版本。

已返回:成功

示例: "4.0"

company_name

字符串

模块的公司名称。

已返回:成功

示例: "Microsoft Corporation"

compatible_ps_editions

列表 / 元素=字符串

模块兼容的 PS 版本。

已返回:成功

示例: ["Desktop"]

字符串

模块的版权。

已返回:成功

示例: "(c) 2016 Warren F. All rights reserved."

dependencies

列表 / 元素=字符串

此模块所需的模块。

已返回:成功

description

字符串

模块的描述。

已返回:成功

示例: "Provides cmdlets to work with local users and local groups"

dot_net_framework_version

字符串

模块的 .Net Framework 版本。

已返回:成功

示例: "4.6.1"

exported_aliases

列表 / 元素=字符串

从模块导出的别名。

已返回:成功

示例: ["glu", "slu"]

exported_cmdlets

列表 / 元素=字符串

从模块导出的 cmdlet。

已返回:成功

示例: ["Get-Certificate", "Get-PfxData"]

exported_commands

列表 / 元素=字符串

从模块导出的所有命令。包括函数、cmdlet 和别名。

已返回:成功

示例: ["glu", "Get-LocalUser"]

exported_dsc_resources

列表 / 元素=字符串

从模块导出的 DSC 资源。

已返回:成功

示例: ["xWebAppPool", "xWebSite"]

exported_format_files

列表 / 元素=路径

从模块导出的格式文件。

已返回:成功

示例: ["C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\DnsClient\\DnsCmdlets.Format.ps1xml", "C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\DnsClient\\DnsConfig.Format.ps1xml", "C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\DnsClient\\DnsClientPSProvider.Format.ps1xml"]

exported_functions

列表 / 元素=字符串

模块导出的函数。

已返回:成功

示例: ["New-VirtualDisk", "New-Volume"]

exported_type_files

列表 / 元素=路径

模块导出的类型文件。

已返回:成功

示例: ["C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\DnsClient\\DnsCmdlets.Types.ps1xml", "C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\DnsClient\\DnsConfig.Types.ps1xml", "C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\DnsClient\\DnsClientPSProvider.Types.ps1xml"]

exported_variables

列表 / 元素=字符串

模块导出的变量。

已返回:成功

示例: ["GitPromptScriptBlock"]

exported_workflows

列表 / 元素=字符串

模块导出的工作流。

已返回:成功

file_list

列表 / 元素=路径

模块包含的文件。

已返回:成功

示例: ["C:\\Program Files\\WindowsPowerShell\\Modules\\PowerShellGet\\1.6.0\\PSModule.psm1", "C:\\Program Files\\WindowsPowerShell\\Modules\\PowerShellGet\\1.6.0\\PSGet.Format.ps1xml", "C:\\Program Files\\WindowsPowerShell\\Modules\\PowerShellGet\\1.6.0\\PSGet.Resource.psd1"]

guid

字符串

模块的GUID。

已返回:成功

示例: "74c9fd30-734b-4c89-a8ae-7727ad21d1d5"

help_info_uri

字符串

模块的帮助信息地址。

已返回:成功

示例: "https://go.microsoft.com/fwlink/?linkid=390823"

icon_uri

字符串

模块图标的地址。

已返回:成功

示例: "https://raw.githubusercontent.com/powershell/psscriptanalyzer/master/logo.png"

installed_date

字符串

模块安装日期。

已返回:成功

示例: "2018-02-14T17:55:34.9620740-05:00"

installed_location

字符串

模块安装路径。

这应该与module_base的值相同,但只有在通过PowerShellGet安装模块时才会有值。

已返回:成功

示例: "C:\\Program Files\\WindowsPowerShell\\Modules\\posh-git\\0.7.1"

license_uri

字符串

模块许可证的地址。

已返回:成功

示例: "https://github.com/PowerShell/xPendingReboot/blob/master/LICENSE"

log_pipeline_execution_details

布尔值

确定是否应记录管道执行详细信息事件。

已返回:成功

module_base

字符串

包含模块文件的路径。

已返回:成功

示例: "C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\PKI"

module_list

列表 / 元素=字典

与该模块一起打包的模块列表。

此值很少返回,并且不会自动处理模块。

已返回:成功

guid

字符串

模块的GUID。

已返回:成功

示例: "82fdb72c-ecc5-4dfd-b9d5-83cf6eb9067f"

maximum_version

字符串

模块的最大版本。

已返回:成功

示例: "2.9"

name

字符串

模块名称。

这也可以是模块文件的路径。

已返回:成功

示例: ".\\WindowsUpdateLog.psm1"

required_version

字符串

所需的模块的精确版本。

已返回:成功

示例: "3.1.4"

version

字符串

模块的最小版本。

已返回:成功

示例: "2.0"

module_type

字符串

模块的类型。参见 https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.moduletype

已返回:成功

示例: "Script"

name

字符串

模块名称。

已返回:成功

示例: "PSReadLine"

nested_modules

列表 / 元素=字典

嵌套在此模块中并在其范围内加载的模块列表。

此列表包含完整的模块对象,因此每个项目都可以具有此处列出的所有属性,包括nested_modules

已返回:成功

package_management_provider

字符串

如果模块是从PowerShellGet安装的,则这是使用的包管理提供程序。

已返回:成功

示例: "NuGet"

path

字符串

模块的路径。

已返回:成功

示例: "C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\PKI\\PKI.psd1"

power_shell_host_name

字符串

模块所需的PowerShell主机的名称。

已返回:成功

示例: "Windows PowerShell ISE Host"

power_shell_host_version

字符串

模块所需的PowerShell主机的版本。

已返回:成功

示例: "1.1"

power_shell_version

字符串

模块所需的PowerShell的最小版本。

已返回:成功

示例: "5.1"

prefix

字符串

应用于从模块导出的Verb-Noun命令的默认前缀,生成Verb-PrefixNoun名称。

已返回:成功

private_data

字典

模块使用的任意私有数据。这通常在模块清单中定义。

此模块限制了除ScriptManifest之外的模块类型返回的数据深度。

通常提供PSData并为PowerShellGet提供元数据,但这些字段也以顶级属性的形式显示。

已返回:成功

示例: {"PSData": {"LicenseUri": "https://example.com/module/LICENSE", "ProjectUri": "https://example.com/module/", "ReleaseNotes": "v2 - Fixed some bugs\nv1 - First release\n", "Tags": ["networking", "serialization"]}}

procoessor_architecture

字符串

模块的处理器架构。参见 https://docs.microsoft.com/en-us/dotnet/api/system.reflection.processorarchitecture

已返回:成功

示例: "Amd64"

project_uri

字符串

模块项目的地址。

已返回:成功

示例: "https://github.com/psake/psake"

published_date

字符串

模块发布日期。

已返回:成功

示例: "2017-03-15T04:18:09.0000000"

release_notes

字符串

模块的发行说明。这是一个自由文本字段,不应假设任何特定格式。

已返回:成功

示例: "## 1.4.6\n- Update `HelpInfoUri` to point to the latest content\n\n## 1.4.5\n- Bug fix for deadlock when getting parameters in an event\n\n## 1.4.4\n- Bug fix when installing modules from private feeds\n"

repository

字符串

安装模块的PSRepository。

此值不是历史性的。它取决于当前用户当前注册的PSRepositories。

必须使repository_source_location与注册存储库的当前源位置匹配才能获取存储库名称。

如果没有匹配项,则此值将与repository_source_location匹配。

已返回:成功

示例: "PSGallery"

repository_source_location

字符串

安装模块的存储库的源位置。

已返回:成功

示例: "https://www.powershellgallery.com/api/v2"

required_assemblies

字符串

模块所需的程序集列表。

值可以是简单名称或完整路径。

已返回:成功

示例: "['Microsoft.Management.Infrastructure.CimCmdlets.dll', 'Microsoft.Management.Infrastructure.Dll']"

required_modules

列表 / 元素=字典

此模块所需的模块列表。

此列表包含完整的模块对象,因此每个项目都可以具有此处列出的所有属性,包括required_modules

但是,这些模块对象可能不包含完整信息,因此您可能看到的結果与直接查询模块的结果不同。

已返回:成功

root_module

字符串

清单中定义的根模块。

这可以是模块名称、文件名或完整路径。

已返回:成功

示例: "WindowsErrorReporting.psm1"

scripts

列表 / 元素=字符串

导入模块时在调用者的会话状态下运行的脚本(.ps1文件)列表。

此值来自模块清单中的ScriptsToProcess字段。

已返回:成功

示例: ["PrepareEnvironment.ps1", "InitializeData.ps1"]

标签

列表 / 元素=字符串

模块PSData 元数据中定义的标签。

已返回:成功

示例: ["networking", "serialization", "git", "dsc"]

更新日期

字符串

模块上次更新的日期。

已返回:成功

示例: "2019-12-31T09:20:02.0000000"

version

字符串

模块版本。

已返回:成功

示例: "1.2.3"

作者

  • Brian Scholer (@briantist)