Book Image

PowerShell Troubleshooting Guide

By : Mike Shepard
Book Image

PowerShell Troubleshooting Guide

By: Mike Shepard

Overview of this book

Table of Contents (15 chapters)
PowerShell Troubleshooting Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Modularization


Writing a script to accomplish a task can be a daunting process. For those of us that are administrators without any programming background, it might not be straightforward to even know where to start.

For very simple tasks, it might be possible to write the entire script in a single line-by-line flow. While this is possible for the shortest tasks, as we get more comfortable with scripting we will definitely be applying PowerShell to more complex problems. Writing complex scripts in a simple start-to-finish way is bound to cause difficulties. In the following sections, we will give some basic instruction on how to go from an idea to a workable script. We will use the task of copying a production database down to a development server as an example.

Breaking a process into subtasks

The first step is to break the task down into subtasks or steps. A common way to do this is to use a comment statement (starting with the hash character, #) for each step. For our example, it might look...