Search code examples
visual-studiopowershell

Remove "Visual Studio 2022 Developer PowerShell" header in Visual Studio Terminal


Whenever I open the terminal in Visual Studio, I get the following boilerplate header:

**********************************************************************
** Visual Studio 2022 Developer PowerShell v17.5.1
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************

Visual Studio 2022 Developer PowerShell

Looking at the terminal settings in Options > Environment > Terminal, I'm using the following shell location:

C:\Program Files\PowerShell\7\pwsh.exe

Along with the following arguments:

-NoExit -Command "& { Import-Module """$env:VSAPPIDDIR\..\Tools\Microsoft.VisualStudio.DevShell.dll"""; Enter-VsDevShell -SkipAutomaticLocation -SetDefaultWindowTitle -InstallPath $env:VSAPPIDDIR\..\..\}"

Normally, you can remove the powershell header text by adding the -NoLogo flag which "Hides the copyright banner at startup.", but that doesn't seem to have an effect here.

I think this is being generated from the Enter-VsDevShell portion.

The reason this is particularly annoying is I usually have the terminal pinned to the bottom with minimal height, so there's a very high demand on visual real estate.

Any way to remove the startup text here?


Solution

    • Add redirection *>$null to silence all output from Enter-VsDevShell

    • In general, use \" to escape embedded " chars. (which works with both powershell.exe (Windows PowerShell) and pwsh.exe (PowerShell (Core) 7+).

      • In this particular case, embedded quoting is not needed, because the paths start with an (environment) variable reference and are followed by literal subpaths that don't require quoting.
    • Remove the unnecessary enclosure in & { ... } - just ... will do.

    -NoExit -Command "Import-Module $env:VSAPPIDDIR\..\Tools\Microsoft.VisualStudio.DevShell.dll; Enter-VsDevShell -SkipAutomaticLocation -SetDefaultWindowTitle -InstallPath $env:VSAPPIDDIR\..\..\ *>$null"