Skip to content

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

@nsjoseph

Description

@nsjoseph
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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions