2

If I run PowerShell as Admin on Window 10 v1909 and make changes to the terminal window (e.g. changing the buffer), the changes get saved as the should, here's an example, changing the buffer size to 999:

enter image description here

But only if I start it the "same way". A second starting procedure seems to have it's own "storage" and does not give me the same result:

  • Run dialog using with the command powershell and hitting Ctrl+Shift+OK to execute (to make it run as admin

versus

  • Win+X Menu, choosing Windows PowerShell (Administrator)

What exactly is going on differently (internally) when opening PowerShell through one or the other way? Can I force it to open the "same" Powershell by using a switch with the Run dialogue?

My first guess was there are two copies of powershell.exe out there, but both processes show they started the same binary in %WinDir%\System32\WindowsPowerShell\v1.0, with one showing up as PowerShell.exe and the other powershell.exe. It looks like some kind of parameter through the Win+X options, to start a second profile?!

13
  • there is two versions on your system, x86, and x64. If you use the start menu to fire up PowerShell you'd see that. I am slightly taken aback as to why you are using the run to start PowerShell at all. With the exception of you needing to run the PowerShell with specific startup params. Just pin the PowerShell shortcut to your taskbar and click to run. You can pin all 4 shortcuts if that is a need for x86/x64 for the console and x86/x64 for the ISE. If you place them in position 1..4 on the taskar then you can use winkey+ThePosition# to launch. – postanote Aug 22 '20 at 7:34
  • You are not looking at all locations for the exe's. PowerShell Executable locations. Also, of note, even if you do not take the pin to the taskbar suggestion, there are already shortcuts keys to start powershell.exe (again, not Eun dialog needed) WinKey+x+i to start powershell. WInKey+x+a to start powershell as admin. – postanote Aug 22 '20 at 7:56
  • @postanote I was using process manager to see which binary has been started to create the process. Both are from the same directory and it's definitely not powershell_ise.exe. So though both "starting options" used the same exe the whole thing started up differently. I assume some kind of parameter through the Win+X options, since it seems the window uses it's own profile. – Albin Aug 22 '20 at 12:29
  • 1
    that is NOT powershell that you are modifying. it is the windows console that PoSh runs inside of. you can see that more clearly by starting cmd.exe and using the same steps ... you will find the same dialog displayed. [grin] – Lee_Dailey Aug 23 '20 at 0:02
  • 1
    This might offer some imsight: Understanding Windows Console Host Settings. – Keith Miller Aug 23 '20 at 7:40
2

If you start PowerShell directly by executing its executable:

  • 32-Bit: %SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe
  • 64-Bit: %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe

It is indeed different from using the shortcuts provided under ⊞ Win+X or using the shortcuts you find in the start menu when looking for "PowerShell". These shortcuts are stored at %AppData%\Microsoft\Windows\Start Menu\Programs\Windows PowerShell and provide their own settings:

enter image description here

2
  • I'm not using shortcuts (neither the ones in the start menu nor any other I made myself), I'm just using command line (which gets stored in the registry) and Win+X menu. But you are right, the folder you provided stores the settings for the Win+X, thanks! – Albin Aug 23 '20 at 13:26
  • Oh wow, Never though of this! Thank you! – Benyamin Limanto Jan 4 at 14:24
0

Back to your original query... as for this...

What exactly is different when opening PowerShell internally

... that is not a thing at all. Windows PowerShell is part of the OS. Starting PowerShell is the same no matter what. There is no concept of internal/external launching of PowerShell.

When you use the Run command cmd.exe, Win+X, etc these are all new PowerShell instances each time and has nothing to do with storage, etc. Any settings you make in a session is only for that session.

If you want to keep those settings, the only way to do this is, one, create desktop shortcuts or modify the existing shortcuts, (i.e, right-click the shortcut and click properties - just as you would with any other Windows shortcut) and set the properties you want.

The second way, for PowerShell, is to create and use PowerShell profiles. This really day 1 hour 1 in a PowerShell training class.

The PowerShell directories do not exist until you create a profile, or you manually create them is what @JW0914 is trying to say here. Just start powershell.exe and then just do this...

New-Item –Path $Profile –Type File –Force

.. the start powershell_ise.exe and do the same thing and that creates the 'WindowsPowerShell' directory ...

C:\Users\YourUserName\Documents\WindowsPowerShell

and the two profiles will be there as

Microsoft.PowerShell_profile.ps1
Microsoft.PowerShellISE_profile.ps1

These are just empty files, base as noted will a location where you can set whatever preferences you choose and they will be used unless you start powershell.exe or powershell_ise using the -noprofile param.

See the Powershell help docs on it.

The is another version of PowerShell called PowerShell Core (pwsh.exe) and it is cross-platform (Win/OSX/Linux) but does not upgrade/replace Windows PowerShell. They are designed to run side by side. It too has its own paths and profiles, separate from Windows PowerShell paths.

C:\Users\YourUserName\Documents\PowerShell

Microsoft.PowerShell_profile.ps1

There is no ISE for PowerShell Core. The replacement for the ISE for PowerShell core is called Visual Studio Code. And it too has its own profile and that must be in the PowerShell folders.

Microsoft.VSCode_profile.ps1
2
  • 1
    the OP is not showing anything to do with PoSh ... that dialog is the windows console dialog reached via rt-clk on the window icon of the console. it's the same thing you see with cmd.exe, powershell.exe, and with pwsh.exe ... unless you are running the "new" terminal. [grin] – Lee_Dailey Aug 23 '20 at 0:05
  • thanks for all your help. unfortunately you were on the wrong path, the settings I was talking about were saved in the shortcut (win+x) and in the registry (command line) - (see comment from Keith and answer from Thomas). Which settings exactly are stored in the files you referenced? – Albin Aug 23 '20 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.