'pwsh' is not recognized as an internal or external command, operable program or batch file

a console with pwsh is not recognized as an internal or external command error message

PowerShell used to be a Windows-only tool based on .NET Framework. Starting from v6, PowerShell is an open-source, .NET Core-based solution you can run on Linux, MacOS, and Linux.

Starting from PowerShell v7, the PowerShell executable has been renamed to pwsh:

The binary name for PowerShell has been changed from powershell(.exe) to pwsh(.exe). This change provides a deterministic way for users to run PowerShell on machines and support side-by-side installations of Windows PowerShell and PowerShell.

PowerShell executable changes

Going forward, if you want to use v7+ version (which should be the default approach), you need to use pwsh instead of powershell. Using powershell is also possible, but it will not work on non-Windows devices and will use Windows PowerShell v5 on Windows ones.

‘pwsh’ missing

If PowerShell v7+ is not installed, you will get the following error:

'pwsh' is not recognized as an internal or external command, operable program or batch file.

Installing PowerShell v7 (and newer)

To fix the error above you need to install the new PowerShell. There are various ways to do it, but the easiest way for .NET developers is to execute the following command:

dotnet tool update --global PowerShell

It will update or install the latest version of PowerShell, and pwsh command will be available in your command line.

Summary

comments powered by Disqus