The function uses the Test-Path cmdlet to determine whether the
$PSDebugContext automatic variable is populated. If $PSDebugContext is
populated, you are in debugging mode, and "[DBG]" is added to the prompt, as
follows:

[DBG] PS C:\ps-test>

If $PSDebugContext is not populated, the function adds "PS" to the prompt.
And, the function uses the Get-Location cmdlet to get the current file
system directory location. Then, it adds a right angle bracket (>).

For example:

PS C:\ps-test>

If you are in a nested prompt, the function adds two angle brackets (>>) to
the prompt. (You are in a nested prompt if the value of the
$NestedPromptLevel automatic variable is greater than 1.)

For example, when you are debugging in a nested prompt, the prompt resembles
the following prompt:

[DBG] PS C:\ps-test>>>

CHANGES TO THE PROMPT

The Enter-PSSession cmdlet prepends the name of the remote computer to the
current Prompt function. When you use the Enter-PSSession cmdlet to start a
session with a remote computer, the command prompt changes to include the name
of the remote computer. For example:

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, PowerShell uses the default prompt, "PS>".

SAVING THE PROMPT FUNCTION

Like any function, the Prompt function exists only in the current session. To
save the Prompt function for future sessions, add it to your PowerShell
profiles. For more information about profiles, see about_Profiles.