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.
-NoLogo
option on my profile? My profile is C:\Users\name\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1