17
Scripts, Functions, and Script Blocks
In PowerShell, scripts and functions are commands. They have overlapping capabilities and often only differ by common use.
Scripts tend to be used to implement well-defined processes; such scripts often run on a schedule of some kind. A script may include functions or run other scripts, and a script will often use commands from other modules. A script is convenient as it consists of a single .ps1
file.
You can also use a function to implement a single process in the same way as a script. The function might be part of a script, implementing a process, or part of a module. When automating a process, writing a module to host a function might be regarded as slightly less convenient and less simple than writing ...
Get Mastering PowerShell Scripting - Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.