'pwsh' is not recognized as an internal or external command, operable program or batch file
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)
topwsh(.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.
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
- Cross-platform PowerShell was a natural reaction to cross-platform .NET Core.
- Starting from
v6
you can run PowerShell anywhere. - In
v7
the executable was renamed topwsh
to remove potential conflicts with legacy Windows PowerShell v5 which still usespowershell
command. 'pwsh' is not recognized...
message indicates PowerShellv7+
is not installed.- To install the latest PowerShell execute
dotnet tool update --global PowerShell
in your command line. - PowerShell documentation is here.