Videos
What you see for the path is right. It is the path for your user profile (for the console host) and it is normal to not see the folder and the file. You can create it and start using your profile:
new-item -type file -path $profile -force
See here for more: about_Profiles.
This is the case when you mistakenly delete your profile file.
You can manually create the "Microsoft.Powershell_profile.ps1" at the location of your profile.
- execute
$profilein cmd/powershell and you will get the location of your profile. - Create the subsequent folders and the file.
In my case, it was
"D:\OneDrive\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1"
So, I manually create the "
WindowsPowerShell" folder insideDocumentsand the "Microsoft.PowerShell_profile.ps1" file inWindowsPowerShell.Then pasted the content in the profile.
Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme Paradox
Hope this resolves your issue. :)
The answer from harrymc is mostly right, except Microsoft has changed things and moves things around and doesn't update their documentation.
Try this to understand your Powershell "profile" scripts:
PS C:\Users\you> $PROFILE | select-object *
The output will be something like:
AllUsersAllHosts : C:\Program Files\PowerShell\7\profile.ps1
AllUsersCurrentHost : C:\Program Files\PowerShell\7\Microsoft.PowerShell_profile.ps1
CurrentUserAllHosts : C:\Users\you\OneDrive\Documents\PowerShell\profile.ps1
CurrentUserCurrentHost : C:\Users\you\OneDrive\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
Length : 77
This tells you where the profiles are, for you.
The blog post you have found is from 2012 and refers to an older version of Windows. While most of it is still correct, the profile folders are not up to date.
The article you found is more recent from 2023, so is to be
taken seriously.
The "Current user, Current Host" profile location is said to
be in $HOME\Documents\PowerShell, which refers to
C:\Users\USER-NAME\Documents\PowerShell.
If you install OneDrive, it will by default backup the
Documents folder, by relocating it into the OneDrive
sync folder and leaving only a pointer to it in
C:\Users\USER-NAME.
This means that, if you have accepted the default setup of OneDrive, your PowerShell profiles are by default synced to OneDrive, but your reference is to a local folder. The profiles will be backed up to OneDrive, but the reference should stay to the local disk, not to the OneDrive folder in the cloud, to avoid problems when there is no internet connection.