Chapter 13. Working with bunches of objects, one at a time

 

Pretty much the whole point of PowerShell is to automate administration, and that often means you’ll want to perform some tasks with multiple targets. You might want to reboot several computers, reconfigure several services, modify several mailboxes, and so on. In this chapter, you’ll learn three distinct techniques for accomplishing these and other multiple-target tasks: batch cmdlets, WMI methods, and object enumeration.

13.1. Automation for mass management

I know that this isn’t a book about VBScript, but I want to use a VBScript example to briefly illustrate the way that multiple-target administration—what I like to call mass management—has been approached in the past. Consider this example (there’s no need to type this in and run it—we’re just going to discuss the approach, not the results):

For Each varService in colServices
  varService.ChangeStartMode("Automatic")
Next

This kind of approach isn’t common only in VBScript, but is common throughout the world of programming. Here’s what it does:

13.2. The preferred way: batch cmdlets

13.3. The WMI way: invoking WMI methods

13.4. The backup plan: enumerating objects

13.5. Common points of confusion

13.6. Lab