It is a good practice to make a function do only one thing. This means that, when writing a script that must do a series of tasks, you will need multiple functions. In such a case, one function will call another to perform the task. The structure of the script, then, would be to have the called function written before the calling function. When working with several functions within a script, the entire structure could look upside-down.
Now, reading and understanding the script may feel a little challenging.
For instance, I wrote a script for one of my clients that helped them heal a Citrix Virtual Desktop Agent server if it unregistered itself from the Controller for any of several reasons. This script was over 300 lines long, and had a dozen functions that would do the following:
- Find if a server was unregistered
- Send out server unregistered and other...