Useful AWS powershell profile prompt

With having a number of AWS accounts to manage you might find yourself lost as to what account and or credentials you are currently using.

The below function when added to you profile.ps1 will modify your powershell prompt with the current shell AWS credentials and region you are using and add a bit of color to it to help you see it.

So when executing AWS commands you “shouldn’t” get lost as to what account you’re in.


It will also remove it if you open up a normal PowerShell window and don’t have any AWS Credentials loaded in the session.


function prompt 

 $prompt = ""
 $prompt1 = ""
 $prompt2 = "PS "
 if ($StoredAWSCredentials -ne $null)
    $prompt1 += "$StoredAWSCredentials"
 if ($StoredAWSRegion -ne $null) 
    $prompt1 += "@"
    $prompt1 += "$StoredAWSRegion"
    $prompt1 += " "
 $prompt += $pwd.ProviderPath
 $prompt += ">"

 Write-Host $prompt2 -nonewline -foregroundcolor Green
 Write-Host $prompt1 -nonewline -foregroundcolor Yellow
 Write-Host $prompt -nonewline -foregroundcolor Green
 Write-Output " "