13

How I can disable this message that shows when Powershell starts?

The message is:

Loading personal and system profiles took xxx ms

I know it shows when profile loading time is slow.
However I have satisfied my profile loading time.

Is there any way to disable this message?

Note that this message seems like shows on Powershell 5.1+ only.

I using: Powershell 5.1 Windows10 1709

3
  • I have seen it in the past but I don't right now.
    – EBGreen
    Mar 1, 2018 at 16:13
  • 3
    Well, -NoLogo will make it go away.
    – EBGreen
    Mar 1, 2018 at 16:32
  • 3
    How do I set -NoLogo option on my profile? My profile is C:\Users\name\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 Mar 2, 2018 at 12:29

9 Answers 9

17

Change the property of the Powershell link target like this:

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -nologo

Then the message should disappear

14

if you are using Windows Terminal open setting.json file by pressing ctrl+, or from the top menu (the dropdown icon > settings) or access it directely from

%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\

in setting.json go to "profiles" > "list" search for the entry that has

"commandline": "powershell.exe",
change it to 
"commandline": "powershell.exe -nologo",

this works also with pwsh

"commandline": "pwsh.exe", 
change it to 
"commandline": "pwsh.exe -nologo",

you can also use -NoProfile to not loading the PowerShell profile
other commands from powershell Parameters

1
  • This is exactly what I needed since I use MS Terminal for all my PCs now; even at work.
    – MKANET
    May 15 at 21:10
3

Redact it

You might not make it go away because you don't/can't add the -nologo option to the powershell call. So if it offends you you can redact it after it's been displayed.

Step 1: Set a flag

At the end of your profile.ps1 script define a global variable indicating that the previous line needs to be redacted.

$global:RedactPreviousLine = $True

Step 2: Set the prompt

The initial text displayed on each new command line is determined by the prompt function. The prompt function will be called each time powershell returns to user control, which conveniently will be after powershell reports how long it took to load your profile.

The contents of this function can be viewed via the command Get-Command Prompt | select-object -expandproperty scriptblock

Since you're loading a profile file anyway, you can simple recreate the prompt function by adding it at some point above the lines you enter in Step 1. In the prompt function we'll add code to redact the offending message. I chose this variable name because it's unlikely to be used again elsewhere.

function Prompt {
    if ( Test-Path Variable:Global:RedactPreviousLine ) { 
        $cursor = New-Object System.Management.Automation.Host.Coordinates
        $cursor.X = $host.ui.rawui.CursorPosition.X
        $cursor.Y = $host.ui.rawui.CursorPosition.Y - 1
        $host.ui.rawui.CursorPosition = $cursor
        Write-host $( " " * ( $host.ui.RawUI.WindowSize.Width - 1 ) )
        $host.ui.rawui.CursorPosition = $cursor

        Remove-Variable RedactPreviousLine -scope global
        } # end if 
    "PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) ";
    # .Link
    # https://go.microsoft.com/fwlink/?LinkID=225750
    # .ExternalHelp System.Management.Automation.dll-help.xml
    } # end function prompt

Review

The way this works is your Profile.PS1 will run, and set the flag. Then the profile.ps1 will end. Powershell will then print the message about how long it took to load your profile and return you to a prompt.

When powershell calls the prompt function, it'll see the global variable RedactPreviousLine and will move the cursor up online fill the line with spaces, return the cursor to the beginning of that same line, and will delete the flag.

Then the prompt function will display the text that makes up the command prompt.

The net effect is that the message will flash on screen then be swiftly removed.

2
  1. Click 'Start' -> type 'powershell' -> 'Open file location'

    OR

    Go to C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Windows PowerShell (change <username> with your username)

  2. If you see 2 versions - 'Windows PowerShell' and 'Windows PowerShell x86' - then do the following for both.

    You could see 2 versions... Windows PowerShell and x86

  3. Right-click and select 'Properties'

    Right-click and select Properties

  4. Within the tabs select the 'Shortcut' tab and append -nologo at the end of the text in 'Target'

    select shortcut and append " -nologo" in the end of Target

  5. Hit 'Apply' and 'Ok' and enjoy a logo-less experience :)

1

You can remove it by deleting the saved profile stored in your CurrentUserCurrentHost. You can access it by simply typing

$profile

or

$profile | Select-Object *

on your power shell. Then you can see the directory in which your profile is stored. Next all you have to do is deleting the profile. Done.

You can refer to the full documentation of Profiles and Execution Policy at: Microsoft docs or if you are more visual person, you can find a good explanation here: John Hammod

1
  • While deleting the profile technically makes the message go away, the OP's is question isn't about that. It is about silencing the message when the profile is loaded.
    – mklement0
    May 15 at 2:11
1

There's good information in the existing answers, but let me provide a systematic overview:

  • The message you're seeing is displayed by default in interactive PowerShell sessions - assuming at least one profile file exists and that the combined loading time exceeds a certain threshold (500 ms. as of PowerShell 7.4). It is preceded by a copyright / product-name message, including a recommendation to try PowerShell (Core) 7+ in Windows PowerShell

    • By contrast, these message are not shown when you call the PowerShell CLI (powershell.exe for Windows PowerShell, pwsh for PowerShell (Core) 7+) with -Command or -File in order to execute a command / script file and then exit (adding -NoExit to -File does show it, however, unless -NoLogo is also passed).
  • If you suppress loading of your profiles, with -NoProfile, the message isn't shown either, but the copyright / product-name message still is.

  • The only way to suppress this message without bypassing loading of profiles altogether is to pass the -NoLogo option on the invocation command line, which invariably also suppresses the copyright / product-name message; in concrete terms:

    • Launch Windows PowerShell with powershell -NoLogo
    • Launch PowerShell (Core) 7+ with pwsh -NoLogo
  • Note:

    • If you're looking for the inverse logic, i.e. if you always want a message showing you how long it took to long profiles, see this answer.

Therefore, to suppress the message you must add -NoLogo to all places you launch interactive PowerShell sessions from:

  • For launching PowerShell from your Start Menu / taskbar (which may launch a regular console window or Windows Terminal, depending on your settings) see Sabito's helpful answer for how to modify the relevant shortcuts; apply the technique analogously to PowerShell (Core) shortcuts.

  • For use in Windows Terminal, press Ctrl+, to open the Settings page, click on the relevant PowerShell profile(s) under Profile in the left sidebar, then click on Command Line in the right pane and append -NoLogo to the executable path.

  • For use in Visual Studio Code's integrated terminal:

    • In the PIC (PowerShell Integrated Console) that comes with the PowerShell extension:

      • Open the Settings page (Ctrl+,), search for "powershell suppress" and check the PowerShell > Integrated Console > Suppress Startup Banner setting.

      • Note that the PIC has its own, host-specific profiles, separate from that used in regular console windows and Windows Terminal, and that loading them must be enabled with the PowerShell: Enable Profile Loading setting.

    • When using PowerShell as a general-purpose shell:

      • Open the Settings page (Ctrl+,), search for "profiles", and, under the platform-appropriate Terminal: Integrated: Profiles: <platform> entry (e.g., Terminal: Integrated: Profiles: Windows on Windows), click on Edit in settings.json

      • In the settings.json file, in the relevant PowerShell profile(s), either add "-NoLogo" to a preexisting "args" property or, if none is present, add:

         "args": [ "-NoLogo" ],
        
2
0

I write this code in my pwsh profile (Microsoft.PowerShell_profile.ps1):

clear ; function Prompt {$Global:Admin=' $' ; $CurrentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent() ; $principal = new-object System.Security.principal.windowsprincipal($CurrentUser) ; if ($principal.IsInRole("Administrators")) { $Admin=' #' } ;
write-host "$env:UserName" -ForeGroundColor Red -NoNewLine ;
write-host "@" -ForeGroundColor Magenta -NoNewLine ;
write-host "$env:ComputerName" -ForeGroundColor Red -NoNewLine ;
write-host " $(get-location)" -ForeGroundColor Green -NoNewLine ;
write-host $Admin -ForeGroundColor Magenta -NoNewLine ;
" "} 

enter image description here

-1

I tried all the techniques so far enumerated in this thread plus a half dozen ideas suggested by ChatGPT...all to no avail. Invariably, whenever I launch Windows Terminal (which I have configured to show a single PowerShell tab), I encounter two lines similar to the following:

PowerShell 7.3.2
Loading personal and system profiles took 538ms.

However, it is possible to make the first line not display by adding Clear-Host to to bottom of the profile Microsoft.PowerShell_profile.ps1.

1
-1

Move to C:\Users{username}\Documents\WindowsPowerShell and delete profile.ps1. Thats it.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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