Skip to main content
  1. Posts/

PowerShell is not recognized as an internal or external command

·143 words·1 min· ·
Xianpeng Shen
Author
Xianpeng Shen
Table of Contents

Recently, while setting up a new Windows Server 2022, I encountered an issue where my Ansible playbook, which previously worked without problems, failed to execute.

Here’s the configuration I used for the Windows host in my Ansible inventory:

[jenkins-agent-windows:vars]
ansible_user=
ansible_ssh_pass=
ansible_connection=winrm
ansible_winrm_transport=ntlm
ansible_winrm_server_cert_validation=ignore

However, when I ran the playbook, the following error occurred:

winrm send_input failed;
stdout:
stderr 'PowerShell' is not recognized as an internal or external command, operable program or batch file.

Cause of the Issue
#

This is usually the case when the SYSTEM’s PATH environment variable has been changed and is no longer able to find PowerShell.exe in the path.

Please verify the PATH environment contains the entry C:\Windows\System32\WindowsPowerShell\v1.0 in there.

Solution
#

Right-click This PC > Properties > Advanced system settings > Environment Variables.

After adding C:\Windows\System32\WindowsPowerShell\v1.0 to PATH, the error disappeared, and my Ansible playbook executed successfully.

Related

What Optimizations I Made During the Jenkins Upgrade
·481 words·3 mins
This article discusses the optimizations made during the Jenkins upgrade, including using Docker Compose for deployment, refactoring the Jenkins Shared Library, introducing Windows Docker Containers, and more to enhance the efficiency and security of the CI/CD process.
Choices — Often More Important Than Effort
·1859 words·9 mins
Late at night, I often wonder how I ended up where I am today. It all stems from a series of choices I made after graduation!
Conventional Branch Specification Released!
·488 words·1 min
This article introduces the Conventional Branch specification, which provides a structured naming convention for Git branches to enhance readability and collaboration.
I Remember
·818 words·2 mins
Lately, I’ve been listening to Zhao Lei’s songs while driving, especially “I Remember.” This article records my graduation season at Rocket’s China branch and the well wishes from my colleagues.
Farewell Rocket China — A Decade's Journey and a New Beginning
·939 words·2 mins
June 28, 2024, marks my last day at Rocket’s China branch. Looking back on a decade’s journey and forward to a new chapter.
Code Signing — GaraSign
·869 words·2 mins
This article introduces the installation, usage, and verification methods of the GaraSign code signing tool, helping developers achieve secure code signing.