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 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. Functions are the building blocks of more complex code, including...