---
- name: "Ensure '%USERPROFILE%/Documents/PowerShell' directory exists"
  become_user: "{{ user.username }}"
  ansible.windows.win_file:
    path: '%USERPROFILE%\Documents\PowerShell'
    state: directory

- name: Configure initialization script for PowerShell
  become_user: "{{ user.username }}"
  community.windows.win_lineinfile:
    path: '%USERPROFILE%\Documents\PowerShell\Microsoft.PowerShell_profile.ps1'
    create: true
    backup: true
    regex: "Invoke-Expression (&starship init powershell)"
    line: "Invoke-Expression (&starship init powershell)"
