Profiles, Customization & Productivity
PowerShell Intermediate/Advanced
Chapter 11 · Profiles, Customization & Productivity
Fundamentals 11 introduced $PROFILE just far enough to make the ll function persistent. That was only ever a quarter of the real picture — $PROFILE is actually four distinct scripts, and picking the wrong one is exactly why a customization can work perfectly in one PowerShell window and mysteriously not exist in another.
$PROFILE Isn't Just One File — It's Four
"Host" here means the actual application running PowerShell — the classic console, VS Code's own integrated terminal, the ISE, Windows Terminal — and PowerShell treats each one as genuinely separate, even though the underlying engine is identical.
$PROFILE (which really means CurrentUserCurrentHost) only affects one specific host. A customization saved there correctly, working perfectly in the classic console, can appear to simply not exist the moment the exact same account opens VS Code's integrated terminal instead — because that's a different host, reading a different file. This isn't a bug; it's four separate files behaving exactly as documented, once you know they're separate.
Which One Should You Actually Edit?
For anything meant to follow you everywhere — Fundamentals 11's own ll function among them — CurrentUserAllHosts is almost always the right target, not the plain $PROFILE shorthand.
Customizing the Prompt: prompt Is Just a Function
Nothing special about prompt beyond its exact reserved name — PowerShell calls it automatically before displaying every new command line, and whatever string it returns becomes the prompt text.
Write-Output "checking git..." left inside a custom prompt function wouldn't just quietly pollute a variable somewhere — it would visibly break your actual prompt, printing extra unwanted text before it, on every single command. This is the same gotcha as always, just with the highest-visibility consequence possible.
A slightly fancier version, showing the current git branch when there is one:
PSReadLine: the Engine Behind Your Interactive Session
Tab completion, syntax highlighting as you type, and multi-line editing all come from PSReadLine, a module loaded by default in every modern PowerShell session:
Prediction, History Search & Key Handlers
Set-PSReadLineKeyHandler remaps individual keys to built-in editing functions — a genuinely deep customization surface, useful even at this single, well-chosen example's level.
prompt function alone typically attempts. Worth knowing it exists; genuinely outside this course's own PowerShell-core scope.
Putting It Together
Hands-On Exercises
A user reports that customizations saved to $PROFILE work perfectly in the regular PowerShell console but don't appear at all in VS Code's integrated terminal. Explain exactly why, and name the specific $PROFILE property that fixes it.
Explain what the prompt function actually is, and why a stray Write-Output line inside a custom prompt function would visibly break what your prompt looks like — referencing Fundamentals 7's own uncaptured-output rule directly.
Write a function prompt that shows the current path, and — only when inside a git repository — the current branch name in brackets right after it.
Chapter 11 Quick Reference
$PROFILEis four files — CurrentUserCurrentHost (the default shorthand), CurrentUserAllHosts, AllUsersCurrentHost, AllUsersAllHosts- "Host" — the actual application running PowerShell (console, VS Code terminal, ISE, Windows Terminal); each is genuinely separate
$PROFILE.CurrentUserAllHosts— the right target for anything meant to follow you across every hostfunction prompt { ... }— a specially-named function PowerShell calls before every command line; its return value becomes the prompt text- Fundamentals 7's uncaptured-output rule applies to
promptdirectly — a stray line there visibly corrupts your actual prompt, every time - PSReadLine — the module behind tab completion, syntax highlighting, and history-based prediction (
Set-PSReadLineOption,Set-PSReadLineKeyHandler) - Next chapter: Capstone — A Multi-System Automation & Reporting Tool