Error message - "module_stderr": "/bin/sh: 1: powershell: not found\n", when running a powershell through win_command

Iam trying to run the below simple playbook in ansible in windows 10 through ubuntu installed.

But Iam getting error as “module_stderr”: “/bin/sh: 1: powershell: not found\n”, “module_stdout”:
Please let me know how to resolve this issue.

  • name: Run Powershell Scripts
    hosts: localhost
    tasks:
  • name: Run powershell script
    win_command: pwsh.exe -ExecutionPolicy ByPass -File C:/temp/Firstpowershellscript.ps1

Hi Kiran,

Did you got any fix for this ?

im also facing the same issue…

Why localhost? Localhost mean you are running it in the ansible server, not win 10 client