Exercise 2: Interactive Session Function vs. $PROFILE — Possible Solution ==================================================================== WHY THE INTERACTIVE VERSION DISAPPEARS ------------------------------ A function typed directly into an interactive PowerShell session exists only within that session's own current scope, per the scoping behavior Chapter 7 established. Once the window closes, that entire session - and everything defined inside it, including the ll function - is discarded completely. There's nothing preserving it anywhere; it was never written to disk, only held in the running session's memory. WHY THE $PROFILE VERSION PERSISTS ------------------------------ $PROFILE is a real .ps1 script file saved on disk. Per this chapter, PowerShell automatically runs this specific script every single time a new session starts, before you type anything yourself. An ll function defined inside $PROFILE isn't something you re-type each session - it gets freshly (re)defined by the profile script's own automatic execution at the start of every new session, which is why it appears to "persist": it's actually being recreated automatically each time, from a script that itself never goes away. WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly explains that an interactively-defined function lives only in that session's memory and vanishes when the session ends, and correctly explains that a $PROFILE-defined function persists because the profile script itself is saved on disk and automatically re-run at the start of every new session, not because the function somehow survives across sessions on its own.