VSCode PPT never fully loads

PPT version 5.28.5 When the extension loads if never finishes. I tried reverting to earlier versions of the extension and also tried an uninstall/reinstall. I get the same behavior in the previous versions as well. i went back to 5.28.3 then tired 5.28.4. I tried starting VSCode as admin. No luck.
Any ideas on what might be wrong? Here is the output from the PPT channel:

Starting PowerShell Pro Tools host from: c:\Users\rreid.vscode\extensions\ironmansoftware.powershellprotools-5.28.5\out\windows\PowerShellProTools.Host.exe}
Process started
connect

Started to PowerShell Pro Tools process.
Connecting to PowerShell process 11924

Tool: Visual Studio, Visual Studio Code, PSScriptPad, PowerShell Module
Version:

I just reproduced this. We have a concurrency issue but it doesn’t seem to happen all the time. It seems that it happens more often with larger workspaces.

I’ve done a little work to try and synchronize the connection process during start up and add some logging. Can you please see if this build solves the issues?

Nope, seems worse now as i dont get anything in the output channel and it still spins. However, it could be a windows security issue since i keep getting a security block on trying to load code.exe. I have to hit unblock 3 or 4 times before it goes away. I am assuming that the vsix is not signed and that is why i am getting the security block.
Another piece of information that might help, i am getting a trust request in VSCode now where i need to set the working folder as a trusted location. first time that i am getting that. here is my vscode info:
vscodever

I take it back, it did finally load but took a looong time. Here is what was in output:

Starting PowerShell Pro Tools host from: c:\Users\rreid.vscode\extensions\ironmansoftware.powershellprotools-5.28.6\out\windows\PowerShellProTools.Host.exe}

Process started

connect

Connecting to PowerShell process 21992

Opening a remote runspace.

Loading PowerShell Pro Tools module

Executing command: [System.Reflection.Assembly]::LoadFrom(‘c:\Users\rreid.vscode\extensions\ironmansoftware.powershellprotools-5.28.6\out\windows\PowerShellProTools.VSCode.dll’)

Executing command: Import-Module ‘c:\Users\rreid.vscode\extensions\ironmansoftware.powershellprotools-5.28.6\out\windows\PowerShellProTools.VSCode.dll’

Executing command: $Env:PSModulePath += ‘;c:\Users\rreid.vscode\extensions\ironmansoftware.powershellprotools-5.28.6\out\windows…\Modules’

Configuring runspace scheduler.

Executing command:

            Get-Runspace | ForEach-Object {

                $h = $_.GetType().GetProperty('Host', [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic).GetValue($_)

                if ($h.Name -eq 'Visual Studio Code Host') 

                {

                    $_.Id

                }

            }

Executing command:

            Get-Runspace | ForEach-Object {

                $h = $_.GetType().GetProperty('Host', [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic).GetValue($_)

                if ($h.Name -eq 'Visual Studio Code Host') 

                {

                    $_.Id

                }

            }

Executing command:

            Get-Runspace | ForEach-Object {

                $h = $_.GetType().GetProperty('Host', [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic).GetValue($_)

                if ($h.Name -eq 'Visual Studio Code Host') 

                {

                    $_.Id

                }

            }

Executing command:

            Get-Runspace | ForEach-Object {

                $h = $_.GetType().GetProperty('Host', [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic).GetValue($_)

                if ($h.Name -eq 'Visual Studio Code Host') 

                {

                    $_.Id

                }

            }

Executing command:

            Get-Runspace | ForEach-Object {

                $h = $_.GetType().GetProperty('Host', [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic).GetValue($_)

                if ($h.Name -eq 'Visual Studio Code Host') 

                {

                    $_.Id

                }

            }

Executing command:

            Get-Runspace | ForEach-Object {

                $h = $_.GetType().GetProperty('Host', [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic).GetValue($_)

                if ($h.Name -eq 'Visual Studio Code Host') 

                {

                    $_.Id

                }

            }

Executing command:

            Get-Runspace | ForEach-Object {

                $h = $_.GetType().GetProperty('Host', [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic).GetValue($_)

                i

f ($h.Name -eq ‘Visual Studio Code Host’)

                {

                    $_.Id

                }

            }

Executing command:

            Get-Runspace | ForEach-Object {

                $h = $_.GetType().GetProperty('Host', [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic).GetValue($_)

                if ($h.Name -eq 'Visual Studio Code Host') 

                {

                    $_.Id

                }

            }

Executing command:

            Get-Runspace | ForEach-Object {

                $h = $_.GetType().GetProperty('Host', [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic).GetValue($_)

                if ($h.Name -eq 'Visual Studio Code Host') 

                {

                    $_.Id

                }

            }

Executing command:

            Get-Runspace | ForEach-Object {

                $h = $_.GetType().GetProperty('Host', [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic).GetValue($_)

                if ($h.Name -eq 'Visual Studio Code Host') 

                {

                    $_.Id

                }

            }

Executing command:

            Get-Runspace | ForEach-Object {

                $h = $_.GetType().GetProperty('Host', [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic).GetValue($_)

                if ($h.Name -eq 'Visual Studio Code Host') 

                {

                    $_.Id

                }

            }

Executing command:

            Get-Runspace | ForEach-Object {

                $h = $_.GetType().GetProperty('Host', [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic).GetValue($_)

                if ($h.Name -eq 'Visual Studio Code Host') 

                {

                    $_.Id

                }

            }

Executing command:

            Get-Runspace | ForEach-Object {

                $h = $_.GetType().GetProperty('Host', [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic).GetValue($_)

                if ($h.Name -eq 'Visual Studio Code Host') 

                {

                    $_.Id

                }

            }

Executing command:

            Get-Runspace | ForEach-Object {

                $h = $_.GetType().GetProperty('Host', [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic).GetValue($_)

                if ($h.Name -eq 'Visual Studio Code Host') 

                {

                    $_.Id

                }

            }

Executing command:

            Get-Runspace | ForEach-Object {

                $h = $_.GetType().GetProperty('Host', [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic).GetValue($_)

                if ($h.Name -eq 'Visual Studio Code Host') 

                {

                    $_.Id

                }

            }

Found VS Code runspace: 5

Executing command:

$RS = Get-Runspace -Id 5

$RS.Events.SubscribeEvent($null, ‘PowerShell.OnIdle’, ‘PowerShell.OnIdle’, $null, {

    try {

    $PSPCommand = [PowerShellProTools.CommandQueue]::GetCommand()

    if ($PSPCommand) 

    { 

        $PSPResults = Invoke-Expression $PSPCommand.Value

        [PowerShellProTools.CommandQueue]::SetResults($PSPResults, $PSPCommand)

    } 

    } catch { [PowerShellProTools.CommandQueue]::SetResults($_.ToString(), $PSPCommand) }

}, $true, $false)

Scheduling command for main runspace: Import-Module ‘c:\Users\rreid.vscode\extensions\ironmansoftware.powershellprotools-5.28.6\out\windows\PowerShellProTools.VSCode.dll’ -Scope Global

Connected to PowerShell process.

Started PowerShell Pro Tools process.

Scheduling command for main runspace: Get-PSProvider | Select-Object -ExpandProperty Name

Scheduling command for main runspace: Get-Variable | Out-PoshToolsVariable -PassThru | ConvertTo-Json -Depth 1 -WarningAction SilentlyContinue

Thanks. It looks like it’s struggling to find the main runspace and trying over and over again until it finally finds it.

Let me do some more digging.

After looking at the code a bit, I realized that these retries during connection happen rapidly and likely isn’t the culprit.

When activating the extension, are you triggering the activation by opening the PowerShell Pro Tools activity pane? Are all the sections expanded?

The reason I ask is because if they are all expanded during load, it will take some time to retrieve each one of the sections (especially history and modules). They are to load one at a time so it can take a bit to load the sections.

To improve startup performance, you can disable the sections you aren’t using.

I am down to just Providers, Quick Scripts, Variables and Help and Information. Still takes a long time to load. i am beginning to suspect our Windows Defender ATP settings. I am trying to figure out which one is causing the problem so that i can put in an exception.

Ok. Let me know if it turns out to not be the case and I can continue to debug the extension. I’m not seeing long loading times or failures to load at the moment.

It definately is windows defender security. our infosec team had the end user engineering team turn on everything for app guard, protected folders, etc sometime last week. i had to put in exceptions to turn off DEP for VS code exe, PowershellProtools.Host.exe, psscriptpad, and even for msiexec, ccm, pickerhost, etc. i disabled all panels except for quick scripts, variables, and help. Now it loads normally. still need to continue troubleshooting since i think Defender security is preventing the PowershellProtools.Host.exe from attaching to the powershell process(s). That is why the Providers, Host Processes, etc take forever to load. So the problem is on my end and not on yours. Thank you for the help.

1 Like

Just to finish this off. If your org turns on all of the Defender ATP protection settings you will need them to put in an exception to turn off DEP for the following services:
code.exe (enter by name and not path)
PowershellProTools.Host.exe
PSScriptpad.exe