Differences between blue background and black background PowerShell - powershell

I'm wondering why the background of the PowerShell is different when I open it from Run (or Start) and from the shortcut on desktop PowerShell.exe. In the first case the background is blue, in the latter case it's black.
Are there other differences between the two windows of the PowerShell?
EDIT
EDIT 2: in the figure below you can see the powershell processes. Moreover, if I open powershell.exe directly from C:\Windows\System32\WindowsPowerShell\v1.0, the background is blue instead of black (remember that its link on desktop opens a black background powershell).
Regarding the below figure, both processes powershell.exe and Windows PowerShell are located in C:\Windows\System32\WindowsPowerShell\v1.0.
P.S.: the situation described here is the same on Windows 10 and 7.
EDIT 3
If I go in the folder C:\Windows\System32\WindowsPowerShell\v1.0 and I right click on powershell.exe, there isn't the tab Colours, but its link on Desktop has the tab Colours.

Are there other differences between the two windows of the PowerShell?
Probably yes but it's likely to be on the same level. (e.g. from your screenshot the blue console is wider so probably has a higher Width layout setting).
afaics it looks they're both the same powershell.exe with different host settings. But only you can confirm.
How to check if they're the same "PowerShell"
Open Task Manager > Details tab.
You should see 2 processes with name powershell.exe.
Right click > Properties and look at the Location
I suspect they're both C:\Windows\System32\WindowsPowerShell\v1.0
Why is one black and the other blue?
Right click on desktop shortcut > Properties > Colours
These settings are applied when you open PowerShell using this shortcut.
You can do the same for the Windows PowerShell shortcut in the start menu.
(You may have to right click > Open file location to get to the actual shortcut)
For Run > powershell.exe, it's using the settings in the registry as described here.
Edit: So running the powershell.exe directly uses the settings stored in the registry at path HKEY_CURRENT_USER\Console\%SystemRoot%_System32_WindowsPowerShell_v1.0_powershell.exe. Copying and pasting a shortcut does not copy these settings because they are not stored in the exe. I believe but am I not certain that shortcuts will use the settings in HKEY_CURRENT_USER\Console\ by default. You need to edit the properties to change the settings for the shortcut. You could edit them in the registry but this seems like a bad idea as it's not just used by PowerShell.
Related stuff
You can change the defaults in the Properties above.
Options, Font and Layout settings may also differ.
You can see the values for the current console (including run > powershell.exe) by clicking on the PowerShell logo in the top left and going to Properties
related links: $Host, Get-Host and (if using PSReadLine module) Get-PSReadLineOption, Set-PSReadLineOption

Related

Windows Powershell and Command Prompt Issue on Windows 10 OS

I have two queries that needs to be resolved.
How can I resize Windows Powershell to a considerable size in Windows 10? I have already tried using the Properties options and via ** Layout**.
But the moment I re-launch it, the window size goes to an in-proportionate size. (Please check the image attached for this query)
P.S - I also browsed Stack-overflow and found this link - [https://superuser.com/questions/68013/how-can-i-set-the-powershell-default-window-size-in-windows-7] but wasn't able to eliminate the issue. :(
Image - 1: In-proportionate size of Windows Powershell
Other than query #1, I also want to know - when I try to open cmd window in a particular folder, I am not able to see the option reading open cmd window here in the context sensitive menu. For quick reference, I am also attaching one image for this query.
Image - 2: No option to open Command Prompt via context-sensitive menu.
P.S: I am getting the option to open Windows Powershell in the above image
I earnestly request the experts here to guide me on these two queries so that I can use both Windows Powershell and Command Prompt without worrying about the size of the window every time.
I look forward to some quick guidance.
Regards.
You can set it in the properties on Powershell window.
After,
When you reopen Powershell, these settings will be saved. Tune Window Position values as well as needed.
For your 2nd issue, read on this link - https://fossbytes.com/powershell-replaces-command-prompt-windows/
If you aren’t ready to accept this change and ditch Command Prompt,
you can opt out of the WIN+X change. To do this, open Settings >
Personalization > Taskbar. Now, turn the “Replace Command Prompt with
Windows PowerShell in the menu when I right-click the Start button or
press Windows key+X” option to “Off”.
As for this...
open cmd window here in the context sensitive
Option:
You can just select any directory and click the Explorer search bar and type cmd or powershell or pwsh (v6 if you have it installed) and it will start in that directory; As long as you don't have directory configured in you PowerShell profile.
You can add thing to the context menu using the Registry editor
See instructions here:
Add the Command Prompt to the Windows Explorer Right-Click Menu
A hidden functionality in Windows allows you to right click on a directory, and select “Command Prompt Here” from the menu.
https://www.howtogeek.com/howto/windows/add-the-command-prompt-to-the-windows-explorer-right-click-menu
Just as you can for PowerShell
Add PowerShell to Windows Explorer Context Menu in Windows 10
Ever since the days of Windows Vista, it was possible to use Windows Explorer’s context menu to quickly open a command prompt window to a specific location by holding the shift key and right-clicking a folder. The “Open Command Prompt Here” appeared, allowing you to open the command prompt in the folder of your choice.
https://www.petri.com/add-powershell-windows-explorer-context-menu-windows-10
BTW, you can add anything you wish to your SendTo menu as well, just by copying the short cut there, and then that too will show up in the explore context menu for use.
As far as your PowerShell Window being overly large/small. Of course the is not the default and something / someone did that. I seen that, but never had it happen to me.
Have you made a lot of customizations?
Is this only happen in your logged on session, vs other users of the system?
So, are you saying also, you cannot resize the Window using your mouse to another size?
Try this first.
Exit the console host.
Open the PowerShell_ISE
Reset the defaults there using these commands
$PSise.Options.RestoreDefaults()
$PSise.Options.RestoreDefaultConsoleTokenColors()
$PSise.Options.RestoreDefaultTokenColors()
$PSise.Options.RestoreDefaultXMLTokenColors()
Next start the console host from the ISE by clicking the console host icon in the toolbar.
Try and work the properties from there, then close and reopen the console host form the ISE to see if the settings stayed.
Then open the console host from whatever shortcut you normally use and see if the changes remained.
If that does not reposition / resize the console windows then this is Windows proper causing this. Similar to a Window being off screen that you can't get to.
Then right click an open space on the taskbar and select Cascade windows.
If that does not work use the move option from the Taskbar.
Use Shift+Tab to select the console Windows.
Shift+RightClick the taskbar icon of the Window and select move.
The close and check again.
Lastly, if you have not done a lot of customizations, you can grab the default PowerShell regkey from another user / profile and import that into your registry.
If you don't have another default logon to use, just create one, check PowerShell state and the get that regkey to use.
Last thing, I meant to add, if none of the above works and you don't want to take the RegKey route. Create a PowerShell console profile and add this code to it. This of course will run each time you start you console using your profile. Of course adjust as needed,
$ConsoleSettings = (Get-Host).ui.rawui
$ScreenBufferSettings = $ConsoleSettings.buffersize
$ScreenBufferSettings.height = 50
$ScreenBufferSettings.width = 120
# $ConsoleSettings.buffersize = $ScreenBufferSettings
$ScreenSizeSettings = $ConsoleSettings.windowsize
$ScreenSizeSettings.height = 50
$ScreenSizeSettings.width = 120
$ConsoleSettings.windowsize = $ScreenSizeSettings

Assigning Background Colour to Created Shortcut to Console?

I have a PowerShell script that creates a new shortcut via Window Scripting Host.
The target is a console program, and I wish to set the "Screen Background" colour, as seen on the "Colors" tab in the properties of an existing console shortcut.
I can create the shortcut no problem, and once it's created I can edit the Colors tab and change the background colour as wanted via the GUI. I just need to figure out a way to set it via the script that creates it (either during creation, or modifying it after creation).
I've examined the WSH CreateShortcut and WshShortcut documentation, but can find nothing about setting those console appearance properties.
Any suggestions on how to do it?

PowerShell Setting up a folder to open in

My teacher gave me this instruction : "To set-up the default folder for PowerShell to open in, right click the PowerShell icon in the tool tray and select Properties. In the Properties dialog box and in the Start in: text box enter the path to the new directory “C:\Users\Administrator\MyScripts”, then click OK."
However when I go into the properties tab I do not see what he is talking about :( .
This is what I see:
How do I I Do what he wants?
Your teacher is asking you to change the properties of the executable. You are currently looking at the PowerShell console properties.
As you can partially see mine is located:
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
By "tool tray" I assume your teacher meant the Windows taskbar and by "to set-up" I assume he/she meant "to set up"1:
If you:
right-click the PowerShell icon in the taskbar, you get a shortcut menu,
in which you can right-click the first entry in the last section to edit the properties of the shortcut file that started the application:
The resulting dialog will show you the desired Start in: field, which determines that shortcut file's startup folder:
Enter the desired startup folder (C:\Users\Administrator\MyScripts in your case), and click OK.
To determine the shortcut file's own location, switch to the General tab of the dialog and inspect the Location: field.
If you haven't yet pinned PowerShell to your taskbar, the Location: field probably contains C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell.
The shortcut file's own name is Windows PowerShell.lnk, though the .lnk extension is typically hidden.
In other words: by default, the shortcut file's full path is C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell\Windows PowerShell.lnk.
In general, shortcut files (*.lnk) store properties such as executable location, startup folder, initial window state, and shortcut key.
As for what you've tried:
As Matt states in his answer, you've invoked the Properties dialog for the open PowerShell console window via its system menu (windows menu), which allows you to persistently change window properties, but not the startup folder.
1 "To set up" is a phrasal verb - no punctuation needed, and not to be confused with the noun derived from it, "setup".

Is it possible to change Windows XP "Jumplist"

I want to change the context menu of any application that is attached to the taskbar (should be the same as clicking a folder icon left, e.g. this)
Is there any way to do this for Windows XP?
If I understand your question, you need system wide hook that handles WM_SYSCOMMAND message to modify system menu. See similar question in c#.
Modifying global system menus

How to go fullscreen in PowerShell

Is there a way of making powershell appear in fullscreen? Not only maximize it over the screen, but hiding the top-bar as well?
Also, since this is probably hard to do, how to maximize it according to current resolution?
Try typing the following command:
mode 300
after the window opens
Right click the top bar and select properties. Then depending on your screen resolution select the appropriate size. (under the layout tab).
ALT + ENTER will full screen the powershell window in Windows 10
If this doesn't work right click the title bar > properties > options and make sure "Use Legacy console" is unchecked:
The trick to using PS in a modern fashion is to use a different type of terminal program. I use ConEmu as it is open-source and free.
Not only will it allow you to run the screen maximised, you can have several tabs, clear-type fonts, custom colours et cetera.
Together with the free 'Source Code Pro' font, it makes for a very nice PS environment.
Hope this helps
Display Options -> Fullscreen, or ALT+ENTER should enter fullscreen mode.
You can create a shortcut with
"%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe " -NoExit -Command "mode 300"
The -NoExit option will keep the console open after running the startup command, and the
-Command option of course runs the command on console startup.
Besides, if you're not an administrator or you're running Windows 8 (hence apps run as not privileged by default) you can setup your shortcut to run Powershell as administrator always.
Source
If it would be sufficient to merely maximize your PowerShell window, you can simply add -WindowStyle Maximized to your PowerShell shortcut:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -WindowStyle Maximized