These are my personal PowerShell profiles with a customized prompt. The primary style of my prompt was to have a visual indicator as to what version of PowerShell I am running. I tend to work in PowerShell 7.0 more than PowerShell 5.1; however, due to some compatability issues with 7.0, I have to flip-flop between the two. Most of my compatability concerns lie with some Microsoft modules not supporting .NET Core yet (Crazy, right?) or if I have to do something that can only be done in 5.1.
On Windows, I even have it change the >
to a $
when running in an administrator context.
If using PowerShell 7.0, you need to ensure that a PowerShell
directory exists for your specific platform. Run these commands for your specific platform if you're not sure:
Windows:
if (-not (Test-Path -Path "~\Documents\PowerShell\")) { New-Item -Path "~\Documents\PowerShell\" -Type "Directory" }
macOS/Linux:
if (-not (Test-Path -Path "~\.config\powershell\")) { New-Item -Path "~\.config\powershell\" -Type "Directory" }
Get the RAW URL for the profile you want and then run this command:
# Replace "/Url/goes/here" with the RAW URL of the profile file.
Invoke-WebRequest -Uri "/Url/goes/here" -OutFile $PROFILE
- Changed the handling of the location path if the current directory structure is the user's profile. Instead of showing the whole path, it will show
~
as the location.- For example if the user's profile is
C:\Users\jdoe123
and the current directory isC:\Users\jdoe123\Downloads
, it will show up as~\Downloads
in the prompt.
- For example if the user's profile is