Forum Discussion

Stomachbuzz's avatar
Stomachbuzz
Copper Contributor
Nov 19, 2022

pwsh.exe Not recognized, even after adding path?

Hello,

 

I am trying to use PowerShell to install/run Node Red. No experience with PS and very little with CMD.

First issue:

xxxx cannot be loaded. The file xxxx is not digitally signed. You cannot run this script on the current system..."

 

I went to the Microsoft link provided (https:/go.microsoft.com/fwlink/?LinkID=135170) to read about Execution_Policies

 

I tried to change the policy for a single session using: pwsh.exe -ExecutionPolicy AllSigned

To which I got the error:

pwsh.exe : The term 'pwsh.exe' is not recognized as the name of a cmdlet, function, script file, or operable program..."

 

Looking that up, I found that my 'Environment Variables' were not correct. Specifically, Powershell was not in my path variable. (btw, Why not? There's all types of weird stuff there, why is PS not there?)

So I added it to my path. I copy/pasted the .exe location  C:\Windows\System32\WindowsPowerShell\v1.0

 

It still says pwsh.exe is not recognized.

 

Any ideas?

 

Edition Windows 10 Home
Version 21H2
Installed on ‎4/‎3/‎2021
OS build 19044.2251
Experience Windows Feature Experience Pack 120.2212.4180.0

 

  • LainRobertson's avatar
    LainRobertson
    Silver Contributor

    Stomachbuzz 

     

    I'm a little reluctant to reply given this is about Windows Home as a lot of things remain unconfigurable and different when compared to Windows Enterprise and Professional (and their ilk.)

     

    That said, it's important to note there are two "PowerShells":

     

    • Windows PowerShell (5.1)
    • PowerShell (7.3)

     

    These aren't the same thing.

     

    Windows PowerShell is the traditional version that ships as part of Windows operating systems - i.e. you don't need to install it. This version lives under C:\Windows\System32\WindowsPowerShell\v1.0\ and the shell's name is powershell.exe. This version is Windows-only.

     

    PowerShell (no Windows prefixed) is the cross-platform version of PowerShell.

     

    On Windows, and assuming a system installation has been performed, it lives under C:\Program Files\PowerShell\7\ and the shell's name is pwsh.exe.

     

    So, if you set your path to include C:\Windows\System32\WindowsPowerShell\, you will find powershell.exe but not pwsh.exe, in which case the error is valid.

     

    Here's a convenient landing page that summarises key differences between Windows PowerShell and PowerShell:

     

     

    Cheers,

    Lain

    • felixozuna's avatar
      felixozuna
      Copper Contributor

      mine is vice versa

      PS C:\Windows\System32> powershell --version
      The application to execute does not exist: 'C:\Windows\System32\pwsh.dll'.
      PS C:\Windows\System32> pwsh --version
      PowerShell 7.4.3
      PS C:\Windows\System32>

       Any clue how to fix it?

      LainRobertson 

      • LainRobertson's avatar
        LainRobertson
        Silver Contributor

        felixozuna 

         

        There's not enough information to know your starting position, and the error from the first command doesn't make sense to me, as pwsh.dll doesn't live in %windir%\System32 by default - at least not under PowerShell v7 and above (and it doesn't relate at all to Windows PowerShell).

         

        Do you get anything back from running the following from a command prompt?

         

        %windir%\System32\WindowsPowerShell\v1.0\powershell.exe -Command "[PSCustomObject] $PSVersionTable | Select-Object -Property PSVersion, PSEdition"

         

        Example output

         

        As an aside, "powershell --version" is an invalid command when referencing Windows PowerShell, and it's not the same at all as "pwsh --version". But that's unimportant in the context of the error you received.

         

        Cheers,

        Lain

Resources