Dot sourcing is a feature of PowerShell whereby scripts are run in the scope of the caller rather than a separate sub-scope. When you dot source, variables, functions, psdrives, etc that were created in the script persist in the callers scope. Had you run the same script normally, these objects would have instantiated for the duration of the script then removed and garbage collected. Dot sourcing was, pre V4, a way of creating scripts of functions and then bringing them into the current scope – although with v2, the module does a better job.
Jeff Hicks shows more detail into how dot sourcing works in a new post on his MCPMag column.
No comments:
Post a Comment