"Failed to attach the PowerShell debug engine debugger" error when attempting to run scripts in Visual Studio

"Failed to attach the PowerShell debug engine debugger" error when attempting to run scripts in Visual Studio

Version: PowerShell Tools for Visual Studio 5.x
Issue:
When attempting to run scripts in Visual Studio, an error will be shown when attempting to start the debugger. This can happen both by pressing F5 with a PowerShell script open or by clicking the Start button with a script open.
You will see an error such as:
---------------------------
Microsoft Visual Studio
---------------------------
Failed to attach the PowerShell debug engine debugger to process' [{1f34db4c-6222-4f0f-9aed-4e52f6ef2396}] script.ps1'on computer' xdfa-23s '. An error (code 0x80040154) that usually indicates a corrupted installation has occurred. If the problem persists, repair the visual studio installation through add or remove programs in control panel.

Workaround:
To work around this issue, you can install the ASP.NET and Web development work load for Visual Studio. This will install any missing dependencies that are required for PowerShell Tools for Visual Studio. To install this work load, open the Visual Studio Installer and select the Individual components tab. From there, you can select the ASP.NET and web development tools. 



    • Related Articles

    • KB3007 - Resetting PowerShell Pro Tools (Visual Studio)

      Scope This article applies to Visual Studio 2017, 2019 and 2022 (Community, Professional and Enterprise) with the PowerShell Tools for Visual Studio [2002] extension. Problem The PowerShell Tools for Visual Studio extension will not load or A ...
    • WPF and WinForms app do not appear when running in Visual Studio

      Product: PowerShell Pro Tools for Visual Studio Version: Any Issue: When running a PowerShell WPF or WinForm script, the script will start but it will not show the window at all.  Resolution: 1. When running a WPF form, ensure that the file that is ...
    • KB3004 - Visual Studio Code missing "Package EXE" button

      Symptom The 'Package EXE' button is missing from Visual Studio Code (with the PowerShell Pro Tools extension1 installed). Scenario #1 You don't have a PowerShell script file (*.ps1) file loaded in VS Code Solution Load a PowerShellscript file (*.ps1) ...
    • KB3008 - About PowerShell Pro Tools Licensing

      Scope Anyone who has purchased a license for PowerShell Pro Tools Question How many machines can I install PowerShell Pro Tools (PowerShell module, PowerShell Pro Tools for VS. Code or PowerShell Tools for Visual Studio? Answer PowerShell Pro Tools ...
    • KB3009 - PowerShell Pro Tools for VS Code "failed to connect"

      Scope This article only applies to PowerShell Pro Tools for VS Code on the Windows operating system. If you are using PowerShell Pro Tools for VS Code for Mac or Linux then this article does not apply Problem The PowerShell Pro Tools extension for VS ...