You can fix this error by adding the Windows PowerShell directory to your system's PATH environment variable or by using the full executable path with the dot-slash syntax. The error occurs because your shell cannot locate the PowerShell executable file in your current working directory or in the standard system folders.

What You'll Need

  • A computer running Windows 10 or Windows 11 with a command prompt or Terminal.
  • Administrator privileges on the machine (required to modify environment variables).
  • A terminal window open, such as Command Prompt, PowerShell, or Git Bash.

Step-by-Step

  1. Open the Windows Search bar. Type "PowerShell" and right-click on the "Windows PowerShell" or "PowerShell” application. Select Open file location from the context menu. This will open a File Explorer window showing the folder containing the PowerShell executable.
  2. Locate the executable file. In the File Explorer window that opened, look for a file named powershell.exe. It is usually located in a subfolder named Core or WindowsPowerShell. You may need to click the "View" tab at the top and check "File name extensions" to see the .exe part of the filename clearly.
  3. Copy the full path. Right-click on the powershell.exe file and choose Copy address or Copy path. You will get a string that looks something like C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe or C:\Program Files\PowerShell\7\powershell.exe. Paste this path into a text editor (like Notepad) to keep it safe and to remove any accidental spaces.
  4. Open Environment Variables. Press the Windows Key and type Edit the system environment variables. This will open the System Properties window. Click the Environment Variables button near the bottom right of the window.
  5. Edit the PATH variable. In the Environment Variables window, look for the System variables section (the large pane). Scroll down and find a variable named Path. Select it and click the Edit button. If you are using Windows 10 or 11, the interface is slightly different; you are looking for the Path variable under System variables and will click the Edit or Edit text button.
  6. Add the new path. Click the New button. Paste the path you copied in step 3. If the path contains spaces, it is good practice to surround it with double quotes, though modern Windows handles paths with spaces in the PATH variable automatically.
  7. Save and close. Click OK on the Edit Environment Variables window, then click OK again on the System Properties window. Close any open File Explorer or text editor windows.
  8. Restart your terminal. You must close all existing Command Prompt, PowerShell, or Git Bash windows and open a new one for the changes to take effect. Any existing shell session still holds the old memory of the PATH variable.
  9. Verify the fix. In your new terminal window, type powershell and press Enter. If the path was added correctly, the system will launch PowerShell instead of reporting a command not found error. You should see the PowerShell prompt appear.

Alternative Method: Using the Dot-Slash Syntax

If you do not want to modify your system-wide PATH variable, you can run PowerShell directly by using its full path with the dot-slash syntax. This tells the current shell to execute the program found at that specific location without needing to add it to the system search list.

  1. Open your terminal. Open Command Prompt, PowerShell, or Git Bash.
  2. Run the command. Type the full path to the executable followed by a forward slash and the command name. For example, for the default Windows PowerShell, you would type:
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    For the newer PowerShell Core (version 7), the path is typically:
    /c/Program Files/PowerShell/7/powershell.exe
    Note that in Git Bash, forward slashes are often used instead of backslashes for directory paths.

Common Mistakes

  • Not restarting the terminal. The PATH variable is read only when a new shell session starts. Simply opening a new Command Prompt window is not enough; you must fully close and reopen the application for the changes to be recognized.
  • Using the wrong PowerShell version. Windows often has two versions: the legacy Windows PowerShell (v1.0) and the modern PowerShell Core (v7). If you are trying to run the modern version and are only seeing the legacy one, you may need to add the specific folder for PowerShell Core to your PATH variable as shown in the steps above.
  • Typographical errors in the path. A single missing backslash or an incorrect character in the string will cause the command not found error to persist. It is helpful to copy the path directly from the file explorer rather than typing it out manually.
  • Adding the folder instead of the executable. When adding to the PATH variable, you must point to the powershell.exe file itself, not just the folder that contains it. For instance, adding C:\Windows\System32 will work, but adding C:\Windows\System32\WindowsPowerShell will look for a file named WindowsPowerShell.exe and fail to find it.

Tips

  • Use quotes for paths with spaces. If your path contains spaces, such as in a user profile folder, always wrap the path in double quotes when adding it to the PATH variable. This prevents the system from interpreting the spaces as delimiters between different directories.
  • Keep your PATH clean. Over time, you may add many folders to your PATH variable, which can slow down shell startup and create confusion. Periodically review your PATH variable and remove any folders that are no longer needed.
  • Context-sensitive help. If you are unsure which PowerShell version is installed on your system, type $PSVersionTable.PSVersion in any PowerShell window. This will display the exact version number, helping you determine if you need to configure the PATH for the modern version.

Troubleshooting

If you have followed the steps above but still receive the command not found error, proceed with these checks.

  • Check if the file exists. Manually navigate to the folder you added to the PATH in File Explorer. Ensure that the powershell.exe file is actually present there. Sometimes the path is copied incorrectly, or the file was moved/deleted after the path was recorded.
  • Verify administrator rights. Environment variables are a system-wide resource. If you are not logged in as an administrator, or if the User Account Control (UAC) settings are restricting changes, the system may silently reject the save operation. Try running the Edit the system environment variables shortcut as an administrator.
  • Check for typos. Re-read the path you added to the variable carefully. Ensure you do not have trailing spaces or extra characters. Even a single invisible character or a typo like PowerShell.exe instead of PowerShell.exe can break the command.
  • Reset the PATH variable. If you have been experimenting with your PATH variable and have lost track of its contents, you can reset it to its default state. In the Edit environment variables window, select the Path variable and click Remove for all entries. Then, click New and add the standard Windows system paths, such as %SystemRoot%\system32.

Frequently Asked Questions

Why does bash say command not found for powershell?

This error happens because the bash shell does not know where the powershell executable is located. The shell searches a list of directories defined in your PATH environment variable; if the folder containing PowerShell is not on that list, the shell cannot run the command.

How do I check my current PATH variable?

You can check your PATH variable by opening a terminal window and typing echo $PATH. This will print the entire string of directories separated by colons. In Windows Command Prompt, you would type echo %PATH%.

Does adding to PATH change permanently?

Yes, if you add the directory to the System variables PATH, the change is permanent for all users on that computer. If you add it to the User variables PATH, the change is permanent only for your specific user account.

Can I run PowerShell from any folder?

Only if the folder containing the powershell.exe file is included in your system's PATH variable. If it is not, you must either navigate to that folder in your terminal using the cd command first, or use the full path to the executable as described in the alternative method.

Is the legacy Windows PowerShell still needed?

The legacy Windows PowerShell (v1.0) is included with all modern versions of Windows. However, the modern PowerShell Core (v7) offers many new features and improvements. For most new development and automation tasks, the modern version is recommended, but the legacy version is still functional.

What is the difference between cmd and powershell?

cmd is the traditional Windows command interpreter, while powershell is a more powerful object-oriented shell. PowerShell includes cmdlets, which are built-in commands, and is generally better suited for complex scripting and automation tasks.