Member-only story

Ansible modules — win_command vs win_shell

How to automate the execution of PowerShell or cmd.exe code on windows target hosts using Ansible Playbook with win_command and win_shell modules.

Luca Berton
5 min readOct 13, 2022

What is the difference between win_command vs win_shell Ansible modules?

These two Ansible modules are confused one for another but they’re fundamentally different.

Both modules allow you to execute win_command on a target host but in a slightly different way.

I’m Luca Berton and welcome to today’s episode of Ansible Pilot.

win_command vs win_shell

win_command

  • Executes a command on a remote Windows node
  • it bypasses the Windows shell
  • always set changed to True

win_shell

  • Execute shell commands on Windows target hosts
  • redirections and win_shell’s inbuilt functionality
  • always set changed to True

--

--

Luca Berton
Luca Berton

Written by Luca Berton

I help creative Automation DevOps, Cloud Engineer, System Administrator, and IT Professional to succeed with Ansible Technology to automate more things everyday

No responses yet