Windows PowerShell - Process exited with code 5 (0x00000005)

Dean Egan 50 Reputation points
2024-08-02T06:52:22.5933333+00:00

Hello,

We are seeing many different machines (Windows 10 and Windows 11) that are facing issues with Windows PowerShell

When someone tries to launch Windows PowerShell, the console opens to [Process exited with code 5 (0x00000005)]:

User's image

After further inspection of Event Viewer, many Engine Health errors occur wit "Settings: illegal characters in path"

User's image

Has anyone come across this issue before?

This is causing many downstream issues such as apps failing to install via intune.

This only happens with Powershell 5, PowerShell 7 works fine.

Kind Regards,

Dean

Windows for business Windows Server User experience PowerShell
Windows for business Windows Client for IT Pros User experience Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. S.Sengupta 24,476 Reputation points MVP
    2024-08-03T01:20:30.9033333+00:00

    Error code 5 (0x00000005) typically indicates an "Access Denied" error in Windows. This suggests that PowerShell is failing to launch due to insufficient permissions or other access-related issues.

    Right-click on PowerShell and choose "Run as Administrator."

    If this works, it confirms a permissions issue.

    Open Control Panel > User Accounts > Change User Account Control settings.

    Try lowering the UAC level temporarily.

    Open Command Prompt as admin and run sfc /scannow and hit the Enter button.

    then: DISM /Online /Cleanup-Image /RestoreHealth and hit the Enter button.


  2. MotoX80 36,291 Reputation points
    2024-08-03T14:28:21.9866667+00:00

    That image looks like Terminal, and not Powershell. Did you change some setting to launch Terminal instead of Powershell.exe? Can you just run Powershell?

    User's image

    Settings: illegal characters in path"

    Assuming that error is referring to the system path environment variable, run this statement in pwsh and look for non-ascii characters in folder names.

    ($env:path).split(";") | sort-object
    

    If you don't find anything, run process monitor and trace it.

    https://learn.microsoft.com/en-us/sysinternals/downloads/procmon

    Add a filter to trace powershell and windowsterminal.

    User's image

    Recreate the error and find where Terminal launches Powershell. Look at the command line that Powershell was launched with.

    User's image

    Look at the files that Powershell tries to read and look for strange characters.

    User's image


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.