PSColor and ISE

PowerShell 5.1 on Win10 1709.

Does anyone use PSColor?

I have a weird problem. I added

Import-Module PSColor

in my profile.ps1. In straight Powershell, it works fine. ISE, however, started freezing upon startup. By “freeze” I mean I never get the right-hand window showing the command list, and ISE will take NO input — can’t use the menu, can’t close the window, etc. The only thing I can do is kill it with Task Manager (ProcessExplorer, technically). It wasn’t using any CPU when I did, so it doesn’t appear to be locked in a loop of some sort or anything.

I have confirmed it’s PSColor doing this by eventually narrowing it down to just a one-line profile.ps1 that contains only the above Import-Module line. With that one-line profile, opening PowerShell works fine, opening ISE freezes.

But, if I rename that one line profile.ps1 to pscolor.ps1, start ISE, and then source the file with

. ./pscolor.ps1

it works fine. And the colors work fine, i.e. a subsequent “dir” shows the appropriate colors on the files/directories. Those two things would seem to indicate that PSColor isn’t incompatible with ISE.

So why would the Import-Module freeze it, but only when it’s in the profile?

Any ideas on how I can debug this further (I’m a relative newcomer to PowerShell), or has anyone else ever encountered this?


Hi Vrshell,

I can replicate the problem like you. I would go back to the person who wrote the function and file it as a bug.

Unless you want to debug it yourself :slight_smile:

Thanks for replicating the problem; that at least tells me it’s not just me or my system. The author isn’t responsive, so if it’s going to be debugged, someone else is going to have to do it.

And I’m glad for that someone else to be me, I’m just still relatively new to PS (I know programming/debugging in general). I can see on GitHub the various files that make up the module, but I don’t know where they “live” once they’re installed on my system or how they fit together, and I don’t know quite how to go about debugging the “import-module” statement. Especially since the statement works when sourced or typed directly in PS, as opposed to being in the profile file. Which means I would somehow have to debug it from the profile file, not from sourcing it directly.

Thus, any pointers to places where I could get some clues as to how to start debugging this particular type of problem would be greatly appreciated. :slight_smile:

You’ll find the whole module under “C:\Program Files\WindowsPowerShell\Modules”