September 2018
Beginner to intermediate
214 pages
5h 53m
English
These two Ansible modules are the best way to send any PowerShell or bash commands to a Windows hosts. The win_shell module is more used for running scripts and long or multiline commands, while the command is more for running regular commands that may require extra parameters. The following playbook shows an example code:
- name: run a PowerShell script on a working directory win_shell: C:\scripts\PSscript.ps1 args: chdir: C:\Users\winuser1\Workspace - name: execute a PowerShell command on remote Windows hosts win_command: (get-service wuauserv | select status | Format-Wide | Out-String).trim() register: output - debug: var=output.stdout
Read now
Unlock full access