community.windows.win_psscript_info 模块 – 收集已安装 PowerShell 脚本的信息

注意

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

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

要安装它,请使用:ansible-galaxy collection install community.windows。您需要进一步的要求才能使用此模块,请参阅 要求 了解详细信息。

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

概要

  • 收集通过 PowerShellGet 安装的 PowerShell 脚本的信息。

要求

执行此模块的主机上需要满足以下要求。

  • PowerShellGet 模块

参数

参数

注释

name

字符串

脚本的名称。

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

如果省略,则返回所有脚本。

默认值: "*"

repository

字符串

安装脚本的 PSRepository 的名称。

这会根据 name 选项过滤将返回的脚本。

只会返回从注册的存储库安装的脚本。

如果存储库在脚本安装后使用新的 SourceLocation 重新注册,则这不匹配。

另请参阅

另请参阅

community.windows.win_psrepository_info

收集有关 PSRepository 的信息。

community.windows.win_psmodule_info

收集有关 PowerShell 模块的信息。

示例

- name: Get info about all script on the system
  community.windows.win_psscript_info:

- name: Get info about the Test-RPC script
  community.windows.win_psscript_info:
    name: Test-RPC

- name: Get info about test scripts
  community.windows.win_psscript_info:
    name: Test*

- name: Get info about all scripts installed from the PSGallery repository
  community.windows.win_psscript_info:
    repository: PSGallery
  register: gallery_scripts

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

- name: Get info about all scripts on the system
  community.windows.win_psscript_info:
  register: all_scripts

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

- debug:
    var: missing_repository_scripts

返回值

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

描述

scripts

列表 / 元素=字典

已安装脚本的列表(如果没有任何脚本,则为空列表)。

已返回: 始终

additional_metadata

字典

脚本中包含或在发布脚本期间包含的其他元数据。

此处许多字段在顶层通过一些标准化展示。此处的值可能会因此略有不同。

此处的字段名称大小写差异很大,并且未标准化或转换为 snake_case。

已返回: 成功

author

字符串

脚本的作者。

已返回: 成功

示例: "Ryan Ries"

company_name

字符串

脚本的公司名称。

已返回: 成功

示例: "Microsoft Corporation"

字符串

脚本的版权。

已返回: 成功

示例: "Jordan Borean 2017"

dependencies

列表 / 元素=字符串

脚本的依赖项。

已返回: 成功

description

字符串

脚本的描述。

已返回: 成功

示例: "This scripts tests network connectivity."

icon_uri

字符串

脚本图标的地址。

已返回: 成功

示例: "https://raw.githubusercontent.com/scripter/script/main/logo.png"

installed_date

字符串

安装脚本的日期。

已返回: 成功

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

installed_location

字符串

脚本的安装路径。

已返回: 成功

示例: "C:\\Program Files\\WindowsPowerShell\\Scripts"

license_uri

字符串

脚本许可证的地址。

已返回: 成功

示例: "https://raw.githubusercontent.com/scripter/script/main/LICENSE"

name

字符串

脚本的名称。

已返回: 成功

示例: "Test-RPC"

package_management_provider

字符串

用于安装脚本的 PowerShellGet 包管理提供程序。

已返回: 成功

示例: "NuGet"

power_shell_get_format_version

字符串

PowerShellGet 规范格式的版本。

已返回: 成功

示例: "2.0"

project_uri

字符串

脚本项目的地址。

已返回: 成功

示例: "https://github.com/scripter/script"

published_date

字符串

脚本的发布日期。

已返回: 成功

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

release_notes

字符串

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

已返回: 成功

示例: "## 1.5.5\n- 添加 可选参数 以获取详细信息\n\n## 1.4.7\n- 修复 在事件中获取参数时发生的死锁错误\n\n## 1.1.4\n- 修复 从私有源安装软件包时的错误\n"

repository

字符串

安装脚本的 PSRepository。

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

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

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

已返回: 成功

示例: "PSGallery"

repository_source_location

字符串

安装脚本的存储库的源位置。

已返回: 成功

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

tags

列表 / 元素=字符串

脚本的 AdditionalMetadata 中定义的标签。

已返回: 成功

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

updated_date

字符串

脚本上次更新的日期。

已返回: 成功

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

version

字符串

脚本版本。

已返回: 成功

示例: "1.2.3"

作者

  • Brian Scholer (@briantist)