Prompts

What does your function:\prompt look like?  Here’s mine:

 function prompt
{

    if ($Host.IsAdministrator -eq $null)
    {
        $CurrentUser = [Security.Principal.WindowsIdentity]::GetCurrent();
        $CurrentUserPrincipal = New-Object Security.Principal.WindowsPrincipal $CurrentUser;
        $AdminRole = [Security.Principal.WindowsBuiltinRole]::Administrator;
        Add-Member -InputObject $global:Host -Name IsAdministrator -MemberType NoteProperty -Value (
            [bool](($CurrentUserPrincipal).IsInRole($AdminRole))
        );

    } # if ($Host.IsAdministrator -eq $null)

    # setting the titlebar
    $host.UI.RawUI.WindowTitle = " $(

        $path = Get-Location;

        if ($path.ProviderPath)
        {
            $path.ProviderPath;

        } # if ($path.ProviderPath)
        else
        {
            $path.ToString();

        } # if ($path.ProviderPath)  ... else

    ) $(if ($host.IsAdministrator) { "Administrator "; })[$(

        Get-Date -Format 'yyyy-MM-dd HH:mm:ss')]";

    # setting the prompt
    "`n# $($env:UserDnsDomain.ToLower())\$env:UserName@$env:computerName.$((Get-WmiObject Win32_ComputerSystem).Domain) ".ToLower() + $(
        if ($history = Get-History | Select-Object -last 1)
        {
            ($history.EndExecutionTime - $history.StartExecutionTime).ToString() -replace "\..*";

        } # if ($history = Get-History | Select-Object -last 1)
        else
        {
            "00:00:00";

        } # if ($history = Get-History | Select-Object -last 1) ... else

    ) + " ($([int]((Get-History | Select-Object -Last 1).ID) + 1))`n# $(Get-Location) $('>' * $nestedpromptlevel)> `n";

} # function prompt

The $Host.IsAdministrator is something I set in my CommonFunctionLibrary.ps1:

 Write-Verbose "($(Get-Date)) Testing if user is in Administrator Group";
if ($Host.IsAdministrator -eq $null) 
{

    $CurrentUser = [Security.Principal.WindowsIdentity]::GetCurrent();
    $CurrentUserPrincipal = New-Object Security.Principal.WindowsPrincipal $CurrentUser;
    $Adminrole = [Security.Principal.WindowsBuiltinRole]::Administrator;
    Add-Member -InputObject $global:Host -Name IsAdministrator -MemberType NoteProperty -Value (
        [bool](($CurrentUserPrincipal).IsInRole($AdminRole))
    );

} # if ($Host.IsAdministrator -eq $null)