Note
This module is part of the community.windows collection (version 2.4.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. You need further requirements to be able to use this module, see Requirements for details.
To use it in a playbook, specify: community.windows.win_psrepository.
The below requirements are needed on the host that executes this module.
NuGet >= 2.8.5.201Parameter | Comments |
|---|---|
force boolean | If force has no effect when state=absent. See notes for additional context. Choices:
|
installation_policy string | Sets the Will default to Choices:
|
name string / required | Name of the repository to work with. |
password string added in community.windows 1.10.0 | Password to authenticate against private repository. |
proxy string added in community.windows 1.1.0 | Proxy to use for repository. |
publish_location string | Specifies the URI for publishing modules to this repository. |
script_publish_location string | Specifies the URI for publishing scripts to this repository. |
script_source_location string | Specifies the URI for discovering and installing scripts from this repository. |
source_location aliases: source string | Specifies the URI for discovering and installing modules from this repository. A URI can be a NuGet server feed (most common situation), HTTP, HTTPS, FTP or file location. Required when registering a new repository or using force=True. |
state string | If If Choices:
|
username string added in community.windows 1.10.0 | Username to authenticate against private repository. |
Note
win_psrepository to re-register (add) removed PSGallery, use the command Register-PSRepository -Default instead.CHANGED status on each run as the values will never match and will be “reset” each time.Get-PSRepository and update the playbook to match.See also
Gather information about PSRepositories.
Adds or removes a Windows PowerShell module.
---
- name: Ensure the required NuGet package provider version is installed
ansible.windows.win_shell: Find-PackageProvider -Name Nuget -ForceBootstrap -IncludeDependencies -Force
- name: Register a PowerShell repository
community.windows.win_psrepository:
name: MyRepository
source_location: https://myrepo.com
state: present
- name: Remove a PowerShell repository
community.windows.win_psrepository:
name: MyRepository
state: absent
- name: Add an untrusted repository
community.windows.win_psrepository:
name: MyRepository
installation_policy: untrusted
- name: Add a repository with different locations
community.windows.win_psrepository:
name: NewRepo
source_location: https://myrepo.example/module/feed
script_source_location: https://myrepo.example/script/feed
publish_location: https://myrepo.example/api/module/publish
script_publish_location: https://myrepo.example/api/script/publish
- name: Update only two properties on the above repository
community.windows.win_psrepository:
name: NewRepo
installation_policy: untrusted
script_publish_location: https://scriptprocessor.example/publish
- name: Clear script locations from the above repository by re-registering it
community.windows.win_psrepository:
name: NewRepo
installation_policy: untrusted
source_location: https://myrepo.example/module/feed
publish_location: https://myrepo.example/api/module/publish
force: true
- name: Register a PowerShell repository with credentials
community.windows.win_psrepository:
name: MyRepository
source_location: https://myrepo.com
state: present
username: repo_username
password: repo_password
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/windows/win_psrepository_module.html