Weekend Scripter: The Case of the Disappearing PowerShell Console

Microsoft Scripting Guy, Ed Wilson, is here. So there I was, on a two week trip, out of time, with only my laptop, and I needed to use Windows PowerShell. Most of the time, I use the Windows PowerShell console, but I do occasionally use the Windows PowerShell ISE. At home, I have a nice-sized second monitor that is attached to my laptop—but I do not—actually the truth is, I rarely travel with my second monitor. I have been known to take it with me on a road trip.

So I click to open the Windows PowerShell console and…nothing. Hmm, I try it again. This time I noticed that the Windows PowerShell console had in fact opened—it was just missing. As shown here, I noticed a white underline beneath the Windows PowerShell console icon I have on my tool bar in Windows 10.

I pressed CTRL + Shift + Esc to bring up Task Manager. I saw that Windows PowerShell was in fact running, but I could not see it:

I ended my Windows PowerShell session, closed the Task Manager, and tried again. I confirmed that Windows PowerShell was loading, but it was not visible. Bummer.

Finding a visible Windows PowerShell console

Then I had an idea…

I can use the Windows PowerShell ISE, but I still wanted the Windows PowerShell console. Guess what? There is an icon for the Windows PowerShell console in the tool bar of the Windows PowerShell ISE. I clicked that, and it worked. The icon is shown here:

And that is what I did for two weeks. I clicked the little Windows PowerShell icon on the Windows PowerShell ISE tool bar, and then I had an instance of the Windows PowerShell console I could use. It was not too bad because I often have both the ISE and the console open anyway, but I used to always open the console first—so this was a learning opportunity.

One day, I searched through the registry hoping I could find something that was storing the screen location (usually in pixels in the x and y coordinates). I was hoping to see how it’s opening window position was set, but alas, I did not find it. It might be there, but I could not find it in the 15 minutes I devoted to the task.

Fixing the problem

Eventually I decided to email our internal Windows PowerShell discussion group to see if anyone else had experienced this problem, and if anyone had come up with a solution. After I sent the email, I quickly saw several people replying with +1, which in Microsoft email speak means that they are also having the same problem. Within 15 minutes, someone from our support group replied that I should look at the properties of my Windows PowerShell console window. Remember, that I can get to one via the Windows PowerShell ISE icon.

To find the Windows PowerShell console properties, I click the Windows PowerShell icon in the upper left corner of the Windows PowerShell console window, and then I select Properties from the action menu:

I select the Let System position Window check box on the Layout tab:

He also told me something else that I didn’t know: If the Windows PowerShell console opens off screen, I can click the Windows PowerShell icon on the tool bar to get focus. Then I can press Alt + Spacebar to open the context menu, and press M to enable me to move the Windows PowerShell console via the arrow keys. Cool.

To expand on the Alt+Spacebar and M trick, here’s the quick and easy way to get back a window that’s stuck off-screen:
1. Make sure the hidden window is active.
2. Press Alt+Spacebar and then M.
3. Press any cursor key once.
4. Move your mouse. You’ll see an outline of your window.
5. Left-click anywhere to release the window and make it visible.

I have this happen to me all the time due to docking and undocking with different screen configurations. I solve this by opening the PowerShell window followed by the Win+Left or Win+right keys. I press those a few times and watch the window sneak its
way back into view.