Win_ping issue "Could not find the shell plugin required"

I’m running WSL2 Ubuntu 24.04.2 LTS as Ansible host and a Windows 11 VM on Hyper-V as a remote node with SSH enabled.
The VM is reachable from the host with ping and SSH, however when I run:

ansible myhosts -m win_ping -i inventory.ini

I get an error:

fatal: [my.windows.vm.ip]: FAILED! => {“msg”: “Could not find the shell plugin required (powershell # Windows’ default is cmd, which is not compatible with most scripts.).”}

inventory.ini file:

[myhosts]
my.windows.vm.ip

[all:vars]
ansible_user=plain_text_user
ansible_ssh_pass=plain_text_password
ansible_connection=ssh

remote_tmp=~/.ansible/tmp
ansible_shell_type=powershell
ansible_ssh_common_args='-o StrictHostKeyChecking=no' 

The target VM automatically uses PowerShell once ssh’ed.
I’ve tried setting ansible_shell_type=cmd however the error is nearly the same:

172.22.85.167 | FAILED! => {
“msg”: “Could not find the shell plugin required (cmd # Windows’ default is cmd, which is not compatible with most scripts.).”
}

ansible version: ansible [core 2.18.5]
ansible.windows 2.8.0

This would indicate your ansible_shell_type in the inventory is not ansible_shell_type=powershell but rather ansible_shell_type=cmd # Windows’ default is cmd, which is not compatible with most scripts. (with the comment). Remove the comment and make sure that your inventory is the one actually being used and that there is no ansible_shell_type set anywhere else with a higher precedence.

1 Like

It worked, thank you!