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 will often use commands from other modules. A script is convenient as it consists of a single ps1
file.
Functions can be used to implement a single process in the same way as a script. A 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 a script.
Whether a function is in a script or a module, the function should strive to be simple. It should aim to be great at one job and, if possible, reusable. Reusable or not, functions are a great way of isolating small chunks of complex logic...