windowspowershellpathconfiguration-files

Editing powershell prompt when user profile file doesn't exist


I want to edit my Powershell prompt, as discussed here https://superuser.com/questions/1259900/how-to-colorize-the-powershell-prompt. However, my $profile variable references a path which does not exist, C:\Users\ferdi\OneDrive\Documenti\WindowsPowerShell\Microsoft.PowerShell_profile.ps1. Specifically, the WindowsPowerShell folder does not exist. How do I find the true location of my $profile, so that I can edit it and change my prompt?

Thanks a lot!


Solution

  • The value of the automatic $PROFILE variable is the true location of your profile file, more accurately of the profile file for the current user (you) and the current host (the application hosting PowerShell, typically a console / terminal window).

    It is just that PowerShell doesn't create any profile files by default, and it doesn't even create the directories for them.

    To then edit your profile with Visual Studio Code, for instance, run code $PROFILE or, if no custom text editor is installed, use notepad $PROFILE.