powershellthemesoh-my-posh

PowerShell theme not working in administrator mode


I have managed to install the oh-my-posh theme for my PowerShell prompt; however, the theme is not working when I start the PowerShell prompt in admin mode.

PowerShell in user vs admin mode

I have tried to adjust the profile.ps file by moving the reference to the json file to a public folder

(C:\Users\MyUser\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1):
'oh-my-posh init pwsh --config 'C:\Users\Public\oh-my-posh\themes\jandedobbeleer.omp.json' | Invoke-Expression'

My assumption is that the admin user has access to the 'MyUser' folder. Maybe this is not the problem, and I am looking in the wrong place.

The normal PowerShell window works like a charm.

How can I make the oh-my-posh theme also work with the PowerShell prompt in administrator mode?


Solution

  • For a given user, there is no difference in $PROFILE locations between running non-elevated vs. elevated (verify with $PROFILE | Select *), so if your elevated sessions run with the current user identity, they load the same profile files.

    However, your screenshot shows:


    Unlike the WT session, this regular console window isn't configured to use a Nerd font, which is required in order for icons in oh-my-posh prompts to render properly - see the docs, which also cover how to configure fonts in Visual Studio Code and Visual Studio (use the relevant tabs).

    Therefore, you have two options: