- Enterprise PowerShell Scripting Bootcamp
- Brenton J.W. Blawat
- 331字
- 2021-07-09 21:03:04
Overall script structure
When you are creating scripts, you should adhere to a strict script structure. The structure of the script dictates the order of execution and how things are processed. The following diagram displays the proper method for organizing your script:

It is recommended that you structure your scripts as follows:
- Declare the comment block: To start the scripting process, declare a comment block and include everything that is pertinent to the script. This may include a description, revision information, author, editor, and additional notes.
- Declare the input parameters: After the header, declare your input parameters, if required by the script. The input parameters are required to be directly after the comment block. Input parameters help the developers identify what is being inputted into the script, and what fields are required for proper execution of the script.
- Declare the global variables: You should declare your global variables after the input parameters. Since variables declared in a function only stay within the boundary of the function, the variables you need to use globally should be defined here.
- Declare the functions in order: The next portion of the structure is declaring your functions. If you have functions that call each other, you will want to declare the functions that are needed first in the script. This ensures that your scripts will not error out due to the function not being declared prior to execution.
- Start the execution of the script: After declaring the functions, you can start the execution of the script. This section will call the other functions used by the global variables, and parameters to complete the tasks for the script.
- Declare the end of the script: After execution, it is recommended that you create an indicator that specifies that the script has run successfully. Whether it is a logging of exit codes to a file or pausing the script at the end, it is important for you to create logic to declare proper or improper execution of your script.
推薦閱讀
- Big Data Analytics with Hadoop 3
- 大數(shù)據(jù)導(dǎo)論:思維、技術(shù)與應(yīng)用
- 腦動(dòng)力:Linux指令速查效率手冊(cè)
- 構(gòu)建高質(zhì)量的C#代碼
- ETL with Azure Cookbook
- 走入IBM小型機(jī)世界
- Java開發(fā)技術(shù)全程指南
- PIC單片機(jī)C語言非常入門與視頻演練
- Ruby on Rails敏捷開發(fā)最佳實(shí)踐
- LAMP網(wǎng)站開發(fā)黃金組合Linux+Apache+MySQL+PHP
- 在實(shí)戰(zhàn)中成長:C++開發(fā)之路
- Introduction to R for Business Intelligence
- 經(jīng)典Java EE企業(yè)應(yīng)用實(shí)戰(zhàn)
- PowerMill 2020五軸數(shù)控加工編程應(yīng)用實(shí)例
- 30天學(xué)通Java Web項(xiàng)目案例開發(fā)