community.windows.win_psscript 模块 – 从 PSRepository 安装和管理 PowerShell 脚本
注意
此模块是 community.windows 集合 (版本 2.3.0) 的一部分。
如果您使用的是 ansible 包,则可能已安装此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install community.windows。您需要其他要求才能使用此模块,有关详细信息,请参阅 要求。
要在 playbook 中使用它,请指定:community.windows.win_psscript。
概要
- 向已注册的 PSRepositories 添加或删除 PowerShell 脚本。 
要求
在执行此模块的主机上需要以下要求。
- PowerShellGet模块 v1.6.0+
参数
| 参数 | 注释 | 
|---|---|
| 如果为  选项 
 | |
| 要安装的脚本的最大版本。 当 state=latest 时不可用。 | |
| 要安装的脚本的最小版本。 当 state=latest 时不可用。 | |
| 要安装或删除的脚本的名称。 | |
| 要安装的脚本的确切版本。 不能与 minimum_version 或 maximum_version 一起使用。 当 state=latest 时不可用。 | |
| 确定脚本是仅为  选项 
 | |
| 访问存储库所需的凭据的密码部分。 必须与 source_username 一起使用。 | |
| 访问存储库所需的凭据的用户名部分。 必须与 source_password 一起使用。 | |
| 脚本的所需状态。 
 
 选项 
 | 
备注
注意
- 与 PowerShell 模块不同,脚本不支持多个版本的并排安装。安装新版本将替换现有版本。 
另请参阅
另请参阅
- community.windows.win_psrepository
- 添加、删除或更新 Windows PowerShell 存储库。 
- community.windows.win_psrepository_info
- 收集有关 PSRepositories 的信息。 
- community.windows.win_psmodule
- 添加或删除 Windows PowerShell 模块。 
示例
- 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
