Working with Subroutines

In this section, you’ll learn about how network administrators use subroutines. For many, the use of subroutines will be somewhat new territory and might even seem unnecessary, particularly when you can cut and paste sections of working code. But before we get into the how-to section, let’s go over the what section.

I used to think a subroutine was getting up in the morning, eating breakfast, standing a watch, and going to bed. But I’ve since learned that a subroutine is a named section of code that gets run only when something in the script calls it by name. Nearly every script we’ve worked with thus far has been a group of commands, which have been processed from top to bottom in a consecutive fashion. Although this consecutive ...

Get Microsoft® Windows® Scripting Self-Paced Learning Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.