Skip to content

win_psrepository_copy fails if ProfileList registry path contains key with no ProfileImagePath defined #604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nsjoseph opened this issue Feb 4, 2025 · 0 comments

Comments

@nsjoseph
Copy link

nsjoseph commented Feb 4, 2025

SUMMARY

win_psrepository_copy fails when the ProfileList registry key contains a subkey for a profile that is invalid with no ProfileImagePath defined.

Example of a profile registry key:

Image

ISSUE TYPE
  • Bug Report
COMPONENT NAME

win_psrepository_copy module

ANSIBLE VERSION
ansible-playbook [core 2.15.13]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.11/site-packages/ansible
  ansible collection location = /runner/requirements_collections:/root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.11.10 (main, Sep  9 2024, 00:00:00) [GCC 11.5.0 20240719 (Red Hat 11.5.0-2)] (/usr/bin/python3.11)
  jinja version = 3.1.4
  libyaml = True
COLLECTION VERSION
# /root/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.windows 2.3.0
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
- name: Copy the current user's PSRepositories to all non-service account profiles and Default profile
  community.windows.win_psrepository_copy:

Executed when there is a Profile in the ProfileList that is in a semi-corrupted state that has no ProfileImagePath defined:

Image

EXPECTED RESULTS

Either all the time, or configurable through a module parameter, ignore keys that have no ProfileImagePath defined.

Alternatively, or in conjunction, allow the include/exclude filtering to occur BEFORE enumerating all of the defined profiles - as currently the Get-ProfileDirectory function used in the module performs the filtering AFTER attempting to enumerate all paths.

ACTUAL RESULTS
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: at <ScriptBlock>, <No file>: line 194
fatal: [server]: FAILED! => {"changed": false, "msg": "Unhandled exception while executing module: Property \"ProfileImagePath\" cannot be found."}

Exception details:

exception: "Property \"ProfileImagePath\" cannot be found.\r\nAt line:141 char:65\r\n+ ...  | Get-ItemProperty | Select-Object -ExpandProperty ProfileImagePath)\r\n+                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n    + CategoryInfo          : InvalidArgument: (@{RunLogonScrip....Core\\Registry}:PSObject) [Select-Object], PSArgumentException\r\n    + FullyQualifiedErrorId : ExpandPropertyNotFound,Microsoft.PowerShell.Commands.SelectObjectCommand\r\n\r\nScriptStackTrace:\r\nat Get-ProfileDirectory, <No file>: line 139\r\nat <ScriptBlock>, <No file>: line 194\r\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant