I have worked with several customers beginning to use Ansible for Windows automation as an effort to standardize within their organization. Almost always, this requires migrating from PowerShell scripts to Ansible playbooks. Fortunately, you can take a phased approach - Ansible can execute PowerShell via the ansible.windows.win_powershell module. Eventually, you will want to convert those PowerShell scripts to use more purpose-built modules. One way to ease the transition is to augment your PowerShell scripts to work with Ansible before you begin the refactoring journey. In this post, I will provide an example using some special variables to generate structured output for playbooks that need to leverage output from a script.
Autodotes Blog Post:
https://autodotes.com/posts/vXdFv526S5anStfuArXM
Source Code:
https://github.com/zjleblanc/ansible-windows-mgmt/blob/master/demos/get_share_stats.yml
Download
0 formats
No download links available.
Powershell with Ansible Tip: Structured Output | NatokHD