community.windows.win_psscript_info (2.2.0) — module

Gather information about installed PowerShell Scripts

Authors: Brian Scholer (@briantist)

Install collection

Install with ansible-galaxy collection install community.windows:==2.2.0


Add to requirements.yml

  collections:
    - name: community.windows
      version: 2.2.0

Description

Gather information about PowerShell Scripts installed via PowerShellGet.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Get info about all script on the system
  community.windows.win_psscript_info:
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Get info about the Test-RPC script
  community.windows.win_psscript_info:
    name: Test-RPC
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Get info about test scripts
  community.windows.win_psscript_info:
    name: Test*
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Get info about all scripts installed from the PSGallery repository
  community.windows.win_psscript_info:
    repository: PSGallery
  register: gallery_scripts
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update all scripts retrieved from above example
  community.windows.win_psscript:
    name: "{{ item }}"
    state: latest
  loop: "{{ gallery_scripts.scripts | map(attribute=name) }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Get info about all scripts on the system
  community.windows.win_psscript_info:
  register: all_scripts
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
    }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug:
    var: missing_repository_scripts

Inputs

    
name:
    default: '*'
    description:
    - The name of the script.
    - Supports any wildcard pattern supported by C(Get-InstalledScript).
    - If omitted then all scripts will returned.
    type: str

repository:
    description:
    - The name of the PSRepository the scripts were installed from.
    - This acts as a filter against the scripts that would be returned based on the I(name)
      option.
    - Only scripts installed from a registered repository will be returned.
    - If the repository was re-registered after script installation with a new C(SourceLocation),
      this will not match.
    type: str

Outputs

scripts:
  contains:
    additional_metadata:
      description:
      - Additional metadata included with the script or during publishing of the script.
      - Many of the fields here are surfaced at the top level with some standardization.
        The values here may differ slightly as a result.
      - The field names here vary widely in case, and are not normalized or converted
        to snake_case.
      type: dict
    author:
      description:
      - The author of the script.
      sample: Ryan Ries
      type: str
    company_name:
      description:
      - The company name of the script.
      sample: Microsoft Corporation
      type: str
    copyright:
      description:
      - The copyright of the script.
      sample: Jordan Borean 2017
      type: str
    dependencies:
      description:
      - The script's dependencies.
      elements: str
      type: list
    description:
      description:
      - The description of the script.
      sample: This scripts tests network connectivity.
      type: str
    icon_uri:
      description:
      - The address of the icon of the script.
      sample: https://raw.githubusercontent.com/scripter/script/main/logo.png
      type: str
    installed_date:
      description:
      - The date the script was installed.
      sample: '2018-02-14T17:55:34.9620740-05:00'
      type: str
    installed_location:
      description:
      - The path where the script is installed.
      sample: C:\Program Files\WindowsPowerShell\Scripts
      type: str
    license_uri:
      description:
      - The address of the license for the script.
      sample: https://raw.githubusercontent.com/scripter/script/main/LICENSE
      type: str
    name:
      description:
      - The name of the script.
      sample: Test-RPC
      type: str
    package_management_provider:
      description:
      - This is the PowerShellGet package management provider used to install the
        script.
      sample: NuGet
      type: str
    power_shell_get_format_version:
      description:
      - The version of the PowerShellGet specification format.
      sample: '2.0'
      type: str
    project_uri:
      description:
      - The address of the script's project.
      sample: https://github.com/scripter/script
      type: str
    published_date:
      description:
      - The date the script was published.
      sample: '2017-03-15T04:18:09.0000000'
      type: str
    release_notes:
      description:
      - The script's release notes. This is a free text field and no specific format
        should be assumed.
      sample: '## 1.5.5

        - Add optional param for detailed info


        ## 1.4.7

        - Bug fix for deadlock when getting parameters in an event


        ## 1.1.4

        - Bug fix when installing package from private feeds

        '
      type: str
    repository:
      description:
      - The PSRepository where the script was installed from.
      - This value is not historical. It depends on the PSRepositories that are registered
        now for the current user.
      - The C(repository_source_location) must match the current source location of
        a registered repository to get a repository name.
      - If there is no match, then this value will match C(repository_source_location).
      sample: PSGallery
      type: str
    repository_source_location:
      description:
      - The source location of the repository where the script was installed from.
      sample: https://www.powershellgallery.com/api/v2
      type: str
    tags:
      description:
      - The tags defined in the script's C(AdditionalMetadata).
      elements: str
      sample:
      - networking
      - serialization
      - git
      - dsc
      type: list
    updated_date:
      description:
      - The date the script was last updated.
      sample: '2019-12-31T09:20:02.0000000'
      type: str
    version:
      description:
      - The script version.
      sample: 1.2.3
      type: str
  description:
  - A list of installed scripts (or an empty list is there are none).
  elements: dict
  returned: always
  type: list

See also