How to override a function during a Powershell session

Is it possible to override the invitation function specified in the user profile after starting the shell?

+5
source share
2 answers

To change the prompt function at any time, simply run the following command at the PowerShell command prompt:

function prompt { "$env:computername $pwd>" }
+4
source

Yes, just enter the code as usual:

function prompt
{
    $random = new-object random
    $color=[System.ConsoleColor]$random.next(1,16)
    Write-Host ("PS " + $(get-location) +">") -nonewline -foregroundcolor $color
    return " "
}

(credit http://mshforfun.blogspot.com/2006/05/perfect-prompt-for-windows-powershell.html )

+3
source

All Articles