Windows Powershell and Command Prompt Issue on Windows 10 OS - powershell

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

Related

Differences between blue background and black background 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

New to VSCode, can't disable sidebar

I am new to VSCode, long been a holdout with Powershell ISE. I am in a situation where I am doing more with PS7, so have no choice but to use it. The one thing that I cannot seem to find is a way to permanently disable the sidebar. Every time I run a script the stupid thing pops up, and I have to hit CTRL+B to close it. I have tried going into Powershell language specific settings, but the only option I see is sidebar.location.
Is there any way to permanently stop this from popping up?
Here is the solution:
go to settings
search for Debug: Open Debug
choose never open
Allow me just say this. I too use VSCode, Sapien's PS Studio, and the ISE more than the previous two, but also use PowerShell v7.
So, FYI... You do have a choice, You can use PowerShell v7 from the ISE. I do this every day. Well, it's a workaround to do so, but it works just fine.
Here is one of the ways to use PowerShell v7 in the ISE.
Using PowerShell Core 6 and 7 in the Windows PowerShell ISE
The other way I use it is just shelling/branching out to it as needed.
Yet, your question is really a duplicate of this Q&A.
Is there a shortcut to hide the sidebar in Visual Studio Code?
And these potential answers...
you can hide the activity bar by setting up your own keybinding
(code.visualstudio.com/docs/customization/keybindings) for
workbench.action.toggleActivityBarVisibility
and or
In the VS code version 1.43, you can hide or show the side menu or
activity bar by going under the 'VIEW' tab in the nav bar in the top
margin of VS CODE(called the 'Menu Bar'). Go to View => Appearance,
there you can check or uncheck different nav bars to show/hide each
one.
If you have the top bar (Menu Bar) currently hidden press 'alt' key to
bring it back then follow above instructions to check it to keep it
there permanently if desired.
The thing to remember though is, that sidebar is your file/project explorer and as such critical for normal development. It's how you get to all your files. Sure, you can still get to them using F1 and type a name, but that's kind of painful, vs scrolling to find what you need or opening multiple files in a project at once.

VSCode - Open terminals in a separate window

in VSCode is it possible to open the terminals in a separate window?
So far my research has pointed to a resounding NO but Im curious if anyone has a solution?
Move terminals between windows
It's now possible to move terminals between windows by detaching via
Terminal: Detach Session in one and attaching to another with
Terminal: Attach to Session. In the future this should help enable
cross-window drag and drop!
Lots of changes in v1.58: https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_58.md#terminals-in-the-editor-area
For v1.59 moving the terminal changes - including dragging and dropping onto another window, see https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_59.md#drag-and-drop-terminals-across-windows
Drag and drop terminals across windows
Drag terminals from the tabs
list or editor area of one window into the tabs list, editor area, or
panel of another window.
Terminals in the editor area
Terminals can now be created in or moved to the editor area, enabling a multi-dimensional grid layout that persists and remains visible regardless of panel state.
To use terminals in the editor area, there are several options:
Create via the Create Terminal in Editor Area command.
Move a terminal from the panel to the editor by dragging and dropping from the tabs list.
Running Move Terminal into Editor Area with a terminal focused.
Moving into the editor area via the terminal tab context menu action.
The new terminal.integrated.defaultLocation setting can be set to editor to direct newly created terminals to the editor area by default.
Please Try:
File > Open New Window
Ctrl+Shift+P > Terminal: Create New Terminal in Editor Area
You can add keybinding to the commands as per your convenience.
i think that the OP wants to create a separate window for the terminal but still have the separated terminal linked to the code editor in the original window (that's what i want too). so that when you run the code in the editor the output is shown in the terminal in the separate window. but if you simply open up a new window of vscode and either open a terminal there or drag and drop the terminal from the original window into the new window, the new terminal is not the same session of the terminal. it is a separate independent unconnected terminal. running the code in the editor does not show output in the new separate terminal. all you have achieved is creating a new unconnected terminal. which you could have just accomplished by opening up a regular terminal window i.e. the one from windows os main menu, no need even to use vscode.
This answer is now outdated. See this answer for instructions on moving terminal panes between VS Code windows. This answer still works but is no longer a necessary workaround.
You can't detach the panes in VSCode, which IMO is a bit of a pain since Visual Studio can detach panes all day long.
There is a workaround though, you can open a new window in VSCode and maximize the terminal pane in that window.
One reason you'd want to do this is to have the Python terminal on a second monitor while still being able to use Python interactively (shift+enter way). Attaching/detaching didn't work for me, nor can you open separate terminals.
What you can do is simply resize your one window across the screen borders! Then right click on the terminal tab/header and click Move panel to the left and voila!
Try Сtrl+Shift+c.
For me, it opens the folder the script is within in a command prompt window.
Create a new window by going to File → New Window.
Open up a new terminal inside of it.
Go to your folder (cd your\projectfolder\path).
And here you are, you have a terminal for your project inside it's own seperate window.
You can change the terminal to be side-by-side instead of below the editor. And then make your window very wide. It is almost as good as having two windows.
Right click on the TERMINAL tab.
Select "Move Views to Side Panel"
Make your window very wide
It seems VS Code allows you to detach the terminal window, but it then will not show the output from the editor of the window you detached it from.
I have spent a while searching, and there is really no workaround other than to just run whatever file you are trying to debug from a separate terminal from the same CWD. This also means you will need to save the file in the window you are editing the file in every time you want to run it. huge pain.
If you are using PowerShell inside the VSCode terminal, why don't you use the PowerShell console from the start menu. It's basically equivalent to using the terminal in separate windows. Hope it helps.Sample

Import/export Chrome devtools breakpoints & settings between computers

Quoting the original idea:
I came across a problem where I need to share all my debugger breakpoints to my colleague to debug the issue at his end. So thought of implementing something like export the debugger points from one system and import at other system.
Since devtools doesn't provide a built-in import/export feature, is there another way?
Use devtools-on-devtools:
open devtools and switch its Dock side in the menu to a detached (floating) window
in the now detached devtools press CtrlShifti or ⌘⌥i on MacOS,
which will open devtools-on-devtools in a new window
UI method:
in this new window switch to Application tab, expand Local Storage, then devtools://devtools on the left
double-click breakpoints value on the right and copypaste it
Now do the same on the target computer and reopen the main devtools window afterwards.
Console method (especially useful if the value is too long):
run copy(localStorage.breakpoints) in devtools-on-devtools console on the source computer to copy the value to clipboard
run localStorage.breakpoints=prompt() on the target computer
(the prompt will appear in the main devtools window).
Console method to export everything:
run copy(JSON.stringify(localStorage)) in devtools-on-devtools console on the source computer to copy the value to clipboard
run Object.assign(localStorage, JSON.parse(prompt())) on the target computer
(the prompt will appear in the main devtools window).
P.S. Next time you can quickly toggle the detached state of devtools by pressing CtrlShiftD

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".