'Flutter Command - Powershell.exe not in PATH error message

I have flutter installed and everything works fairly alight but every time I run a flutter command I get the following message before the command actually runs.

Error: PowerShell executable not found. Either pwsh.exe or PowerShell.exe must be in your PATH.

I added the Powershell.exe path to my PATH variable (both System & User) and also added C:\Windows\System32 as I read that on one of the Github/SO forums. Any idea how to get rid of this? I am following a Udemy course and have followed every instruction to the dot but the instructor does not get this message.



Solution 1:[1]

Go "Edit environment variables for your account" under "User variables" add to Path this line

C:\Windows\System32\WindowsPowerShell\v1.0

It solved my problem.

Solution 2:[2]

Add this to user Path variables and system path variables

  1. C:\src\flutter\bin

Add these to Environment System Path Variables

  1. C:\Program Files\Git\cmd
  2. C:\Windows\System32\WindowsPowerShell\v1.0\
  3. C:\Windows\System32

My problem was the missing of 3rd from System path variables.

Solution 3:[3]

copy the path, for my case, it is "C:\Windows\System32\WindowsPowerShell\v1.0" and pastes it in environment variables as a path

Solution 4:[4]

I have lost half a day to solve it and used all instructions on flutter site and and answers about powershell path. It didnt work until add C:\Windows\System32 to Path variable.

Solution 5:[5]

In case you encountered this problem and none of the above solutions worked for you. In my case, I set all the environment variables - I am using Windows 10. I even reinstalled flutter; but the problems persisted.

It turns out my Anti Virus had quarantined the Powershell executable file. I had to open the anti virus quarantine chest, restored the Powershell executable and restarted my VS Code.

Problems solved, after three days of searching for solutions.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Abdurrahman O?uzhan Durmaz
Solution 2 Foysal Khandakar Joy
Solution 3 Akhil
Solution 4 Roman Kononykhin
Solution 5 Psalms Kalu