Camkode
Camkode

Fixing "'pwsh' is not recognized" Error in PowerShell Core

Posted by Kosal

Fixing "'pwsh' is not recognized" Error in PowerShell Core

Are you facing the error "'pwsh' is not recognized as an internal or external command, operable program, or batch file" when trying to use PowerShell Core on your system? This common issue can be frustrating, but fear not – there's a simple solution.

The Problem:

The error message indicates that your system is unable to locate the pwsh executable, which is the command-line interface for PowerShell Core. This typically happens when the installation directory of PowerShell Core is not added to your system's PATH environment variable.

The Solution:

Thankfully, resolving this issue is straightforward. You can quickly fix it by updating the global PowerShell tool using the .NET CLI (dotnet). Here's how:

  1. Open a Terminal or Command Prompt: Begin by opening a terminal or command prompt on your system. This is where you'll execute the necessary commands.
  2. Update PowerShell Core: Run the following command in your terminal or command prompt:
dotnet tool update --global PowerShell

This command updates the global PowerShell tool to the latest version available, ensuring that pwsh is correctly installed and accessible from any directory on your system.

  1. Verify Installation: Once the update process is complete, you can verify that PowerShell Core is now working correctly. Simply type pwsh in your terminal or command prompt, and if everything is set up correctly, PowerShell Core should start without any errors.

Additional Notes:

  • If you encounter any errors during the update process, ensure that you have the .NET SDK installed on your system. You can download it from the official .NET website.
  • After updating the global PowerShell tool, you may need to restart your terminal or command prompt for the changes to take effect.

By following these steps, you should be able to resolve the "'pwsh' is not recognized" error and use PowerShell Core seamlessly on your system.