community.windows.win_psscript (2.2.0) — module

Install and manage PowerShell scripts from a PSRepository

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

Add or remove PowerShell scripts from registered PSRepositories.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install a script from PSGallery
  community.windows.win_psscript:
    name: Test-RPC
    repository: PSGallery
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Find and install the latest version of a script from any repository
  community.windows.win_psscript:
    name: Get-WindowsAutoPilotInfo
    state: latest
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove a script that isn't needed
  community.windows.win_psscript:
    name: Defrag-Partition
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install a specific version of a script for the current user
  community.windows.win_psscript:
    name: CleanOldFiles
    scope: current_user
    required_version: 3.10.2
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install a script below a certain version
  community.windows.win_psscript:
    name: New-FeatureEnable
    maximum_version: 2.99.99
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Ensure a minimum version of a script is present
  community.windows.win_psscript:
    name: OldStandby
    minimum_version: 3.0.0
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install any available version that fits a specific range
  community.windows.win_psscript:
    name: FinickyScript
    minimum_version: 2.5.1
    maximum_version: 2.6.19

Inputs

    
name:
    description:
    - The name of the script you want to install or remove.
    required: true
    type: str

scope:
    choices:
    - current_user
    - all_users
    default: all_users
    description:
    - Determines whether the script is installed for only the C(current_user) or for C(all_users).
    type: str

state:
    choices:
    - present
    - absent
    - latest
    default: present
    description:
    - The desired state of the script. C(absent) removes the script.
    - C(latest) will ensure the most recent version available is installed.
    - C(present) only installs if the script is missing.
    type: str

repository:
    description:
    - The registered name of the repository you want to install from.
    - Cannot be used when I(state=absent).
    - If ommitted, all repositories will be searched.
    - To register a repository, use M(community.windows.win_psrepository).
    type: str

maximum_version:
    description:
    - The maximum version of the script to install.
    - Cannot be used when I(state=latest).
    type: str

minimum_version:
    description:
    - The minimum version of the script to install.
    - Cannot be used when I(state=latest).
    type: str

source_password:
    description:
    - The password portion of the credential required to access the repository.
    - Must be used together with I(source_username).
    type: str

source_username:
    description:
    - The username portion of the credential required to access the repository.
    - Must be used together with I(source_password).
    type: str

allow_prerelease:
    default: false
    description:
    - If C(yes) installs scripts flagged as prereleases.
    type: bool

required_version:
    description:
    - The exact version of the script to install.
    - Cannot be used with I(minimum_version) or I(maximum_version).
    - Cannot be used when I(state=latest).
    type: str

See also