Dot-Sourcing

noun

say it: “DOT SORSS-ing” /ˈdɑt ˈsɔrsɪŋ/

Running a script so that the variables and functions it creates stay in your session afterwards.

What is dot-sourcing?

Dot-sourcing runs a script with a dot and a space in front of its path. A script run the usual way works in a room of its own that is cleared when it ends; dot-sourced, it works in your session, so what it sets stays. . $PROFILE reloads your profile this way.

.\settings.ps1       # $snackBudget is gone when it ends
. .\settings.ps1     # $snackBudget stays

In a sentence

  • “Sam reloaded his profile by dot-sourcing it.”
  • “With dot-sourcing, $snackBudget was still there after the script ended.”

Level: Apprentice · More PowerShell terms at this level

Updated