Вы находитесь на странице: 1из 2

$currentDirectory >"

The following prompt uses the Write-Host and


Get-Random cmdlets to create
a prompt that changes color randomly. Because
Write-Host writes to the
current host application but does not return
an object, this function
includes a Return statement. Without it, Wind
ows PowerShell uses the
default prompt, "PS>".

function prompt
{
$color = get-random -min 1 -max 16
write-host ("PS " + $(get-location)
+">") -nonewline -foregroundcolor $color
return " "
}

Saving the Prompt

Like any function, the Prompt function applie


s only in the current
session. To save the Prompt function for futu
re sessions, add it to your
Windows PowerShell profiles. For more informa
tion about profiles,
see about_Profiles.

SEE ALSO
Get-Location
Enter-PSSession
Get-History
Get-Random
Write-Host
about_Profiles
about_Functions
about_Scopes
about_Debuggers
about_Automatic_Variables

Вам также может понравиться