community.windows.win_psscript – Install and manage PowerShell scripts from a PSRepository

Note

This plugin is part of the community.windows collection (version 1.7.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.windows.

To use it in a playbook, specify: community.windows.win_psscript.

Synopsis

  • Add or remove PowerShell scripts from registered PSRepositories.

Requirements

The below requirements are needed on the host that executes this module.

  • PowerShellGet module v1.6.0+

Parameters

Parameter Choices/Defaults Comments
allow_prerelease
boolean
    Choices:
  • no
  • yes
If yes installs scripts flagged as prereleases.
maximum_version
string
The maximum version of the script to install.
Cannot be used when state=latest.
minimum_version
string
The minimum version of the script to install.
Cannot be used when state=latest.
name
string / required
The name of the script you want to install or remove.
repository
string
The registered name of the repository you want to install from.
Cannot be used when state=absent.
If ommitted, all repositories will be searched.
To register a repository, use community.windows.win_psrepository.
required_version
string
The exact version of the script to install.
Cannot be used with minimum_version or maximum_version.
Cannot be used when state=latest.
scope
string
    Choices:
  • current_user
  • all_users
Determines whether the script is installed for only the current_user or for all_users.
source_password
string
The password portion of the credential required to access the repository.
Must be used together with source_username.
source_username
string
The username portion of the credential required to access the repository.
Must be used together with source_password.
state
string
    Choices:
  • present
  • absent
  • latest
The desired state of the script. absent removes the script.
latest will ensure the most recent version available is installed.
present only installs if the script is missing.

Notes

Note

  • Unlike PowerShell modules, scripts do not support side-by-side installations of multiple versions. Installing a new version will replace the existing one.

See Also

See also

community.windows.win_psrepository

The official documentation on the community.windows.win_psrepository module.

community.windows.win_psrepository_info

The official documentation on the community.windows.win_psrepository_info module.

community.windows.win_psmodule

The official documentation on the community.windows.win_psmodule module.

Examples

- name: Install a script from PSGallery
  community.windows.win_psscript:
    name: Test-RPC
    repository: PSGallery

- name: Find and install the latest version of a script from any repository
  community.windows.win_psscript:
    name: Get-WindowsAutoPilotInfo
    state: latest

- name: Remove a script that isn't needed
  community.windows.win_psscript:
    name: Defrag-Partition
    state: absent

- 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

- name: Install a script below a certain version
  community.windows.win_psscript:
    name: New-FeatureEnable
    maximum_version: 2.99.99

- name: Ensure a minimum version of a script is present
  community.windows.win_psscript:
    name: OldStandby
    minimum_version: 3.0.0

- 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

Authors

  • Brian Scholer (@briantist)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/windows/win_psscript_module.html