Enterprise PowerShell Scripting Bootcamp
上QQ阅读APP看书,第一时间看更新

PowerShell scripting templates

As you develop different scripts for your enterprise environment, you will have a core set of functions that you tend to use in all of your scripts. Some enterprise scripters create their own functions, while others leverage scripts from the vast community of PowerShell developers. With either method, you will need a solid foundation to build your scripts on.

Some of the most common items this book provides for scripting templates include:

  • Encryption and decryption technologies: Probably the most common requirement in enterprise environments is security. It's no secret that you should not have clear text administrative-level credentials in scripts. Providing an encryption and decryption function in your scripts is essential to maintaining a secure enterprise.
  • Logging mechanisms: The second most common requirement in enterprise environments is logging script actions. Since scripts are typically executed on a large number of systems at the same time, you will need the ability to track exactly what is being performed on these systems. Creating a logging function will provide the ability to log script actions to both the event log and a log file.
  • Answer file logic: One of the more advanced methods for PowerShell scripting is leveraging an answer file for script variables. The core to the answer file is that you can add, remove, and modify the values in the answer file without having to modify your script. This provides the ability to have flexibility in your scripts without needing to touch any lines of code.
  • Standardized comment blocks: When you are creating scripts, it's essential to give yourself and others reminders of what the script's function is. Comment blocks enable the ability to provide details about the script, revision history, and execution parameters of the script.

Whether you are new to PowerShell scripting or you have been scripting for a long time, this book provides thought-inspiring methods to improve your scripting abilities. As you work through this book, it's strongly encouraged to incorporate these examples in your own scripts. This applied learning methodology will significantly help in your retention of the content, and provide a very robust enterprise scripting platform.