1

Here is the powershell command on my playbook:

- name: "Execute Powershell from Ansible"
  ignore_errors: yes
  ansible.windows.win_shell: (Get-Acl -Path "C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Binn") | Format-list

Here is error from ansible:

{
"ansible_loop_var": "item",
"_ansible_no_log": false,
"item": "(Get-Acl -Path \"C:\\Program Files\\Microsoft SQL Server\\MSSQL13.MSSQLSERVER\\MSSQL\\Binn\") | Format-list",
"changed": false,
"msg": "Get-AnsibleParam: Missing required argument: _raw_params",
"_ansible_item_label": "(Get-Acl -Path \"C:\\Program Files\\Microsoft SQL Server\\MSSQL13.MSSQLSERVER\\MSSQL\\Binn\") | Format-list" 
}

2 Answers 2

2

The error is

Missing required argument: _raw_params

Escape the quotes the other way, like this:

- name: Execute Powershell from Ansible
  ansible.windows.win_shell: |
    Get-Acl -Path "C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Binn" | Format-list

And also, do not use ignore_errors: yes as the first module to use.

Sign up to request clarification or add additional context in comments.

Comments

1

Solved! Here is the yaml:

- name: Execute Powershell from Ansible
  win_shell: |
    Get-Acl -Path "C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Binn" | Format-list
    Get-Acl -Path "C:\Program Files\Microsoft SQL Server\130\COM" | Format-list
    Get-Acl -Path "C:\Program Files\Microsoft SQL Server\130\Shared" | Format-list
    Get-Acl -Path "C:\Program Files\Microsoft SQL Server\130\Shared\ErrorDumps" | Format-list

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.