'How to create a mail profile in my remote windows machine using ansible

I'm unable to create a mail profile in my remote windows machine which has Outlook 2016. I havw to create it using ansible.

I tried this:

- name: Manage windows server
  hosts: win
  tasks:
    - name: Setting up default account
      ansible.windows.win_command: outlook.exe /PIM Default
      args:
        chdir: C:\Program Files (x86)\Microsoft Office\root\Office16\

This task just hangs and the profile is not created. Is there any alternative to create a profile through ansible?



Solution 1:[1]

Followed the steps mentioned here: https://docs.microsoft.com/en-us/answers/questions/765131/want-to-create-a-default-outlook-account-in-window.html?childToView=775847#comment-775847

and came up with this:

- name: Add Default Account
  ansible.windows.win_shell: |
    reg add HKCU\Software\Microsoft\Office\16.0\Outlook\Profiles\Default
    reg add "HKCU\Software\Microsoft\Office\16.0\Outlook" /v DefaultProfile /t REG_SZ /d "Default" /F

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Anvay Singh