Working with bunches of objects, one at a time in VB.NET

Generator Data Matrix ECC200 in VB.NET Working with bunches of objects, one at a time

Working with bunches of objects, one at a time
Making Data Matrix In VB.NET
Using Barcode generator for .NET framework Control to generate, create ECC200 image in Visual Studio .NET applications.
www.OnBarcode.com
Data Matrix 2d Barcode Recognizer In VB.NET
Using Barcode recognizer for .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
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.
Barcode Generation In Visual Basic .NET
Using Barcode creation for .NET framework Control to generate, create Barcode image in .NET framework applications.
www.OnBarcode.com
UPCA Maker In Visual Basic .NET
Using Barcode creation for VS .NET Control to generate, create UPC Symbol image in .NET applications.
www.OnBarcode.com
13.1 Automation for mass management
PDF 417 Drawer In VB.NET
Using Barcode encoder for Visual Studio .NET Control to generate, create PDF417 image in VS .NET applications.
www.OnBarcode.com
Drawing Barcode In Visual Basic .NET
Using Barcode maker for Visual Studio .NET Control to generate, create Barcode image in .NET framework applications.
www.OnBarcode.com
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):
ANSI/AIM Code 39 Creation In VB.NET
Using Barcode printer for .NET Control to generate, create USS Code 39 image in VS .NET applications.
www.OnBarcode.com
USPS Intelligent Mail Encoder In Visual Basic .NET
Using Barcode creator for Visual Studio .NET Control to generate, create OneCode image in Visual Studio .NET applications.
www.OnBarcode.com
For Each varService in colServices varService.ChangeStartMode("Automatic") Next
ECC200 Generation In Visual Studio .NET
Using Barcode generation for Reporting Service Control to generate, create Data Matrix ECC200 image in Reporting Service applications.
www.OnBarcode.com
ECC200 Generation In Objective-C
Using Barcode generator for iPad Control to generate, create Data Matrix image in iPad applications.
www.OnBarcode.com
This kind of approach isn t common only in VBScript, but is common throughout the world of programming. Here s what it does:
Linear Maker In C#
Using Barcode printer for Visual Studio .NET Control to generate, create Linear image in .NET applications.
www.OnBarcode.com
Code 39 Full ASCII Encoder In Java
Using Barcode generator for Android Control to generate, create USS Code 39 image in Android applications.
www.OnBarcode.com
Assume that the variable colServices contains multiple services. It doesn t matter how they got in there, because there are many ways you could retrieve the services. What matters right now is that you have already retrieved the services and put them into this variable.
GS1 - 12 Printer In None
Using Barcode creation for Font Control to generate, create UPC-A Supplement 5 image in Font applications.
www.OnBarcode.com
UPC Symbol Printer In Java
Using Barcode maker for Java Control to generate, create GS1 - 12 image in Java applications.
www.OnBarcode.com
The preferred way: batch cmdlets
UCC.EAN - 128 Generation In None
Using Barcode generation for Software Control to generate, create EAN 128 image in Software applications.
www.OnBarcode.com
Paint QR Code In None
Using Barcode encoder for Office Excel Control to generate, create Denso QR Bar Code image in Excel applications.
www.OnBarcode.com
The For Each construct will go through, or enumerate, the services one at a time. As it does so, it will place each service into the variable varService. So, within the construct, varService will only contain a single service. If colServices contained 50 services, then the construct s contents would execute 50 times, and each time, varService would contain a different one of the 50 services. Within the construct, we re executing a method in this example, ChangeStartMode() to perform some task.
Draw Linear 1D Barcode In Visual Studio .NET
Using Barcode generator for Visual Studio .NET Control to generate, create 1D Barcode image in VS .NET applications.
www.OnBarcode.com
EAN / UCC - 13 Creator In VS .NET
Using Barcode generator for Reporting Service Control to generate, create GS1 128 image in Reporting Service applications.
www.OnBarcode.com
If you think about it carefully, you ll realize that we really aren t doing something to a bunch of services at once. Instead, we re doing something to one service at a time, exactly as we would if we were manually reconfiguring the services by using the graphical user interface. The only difference is that we re making the computer go through the services one at a time. Computers are really good at repeating things over and over, so this isn t a horrible approach. The problem is that this approach requires us to give the computer a longer and fairly complicated set of instructions. Learning the language necessary to give that set of instructions can take a while, which is why a lot of administrators try to avoid VBScript and other scripting languages. PowerShell can duplicate this approach, and I ll show you how later in this chapter, because sometimes you have to resort to this method. But the approach of having the computer enumerate objects isn t the most efficient way to use PowerShell. In fact, PowerShell offers two other techniques that are easier to learn and easier to type, and they re often more powerful.
Barcode Generation In None
Using Barcode creator for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
Painting UPC Symbol In None
Using Barcode generation for Software Control to generate, create UPCA image in Software applications.
www.OnBarcode.com
13.2 The preferred way: batch cmdlets
As you ve learned in several previous chapters, many PowerShell cmdlets can accept batches, or collections, of objects to work with. In chapter 7, for example, you learned how objects can be piped from one cmdlet to another, like this (please don t actually run this it ll probably crash your computer):
Get-Service | Stop-Service
This is an example of batch administration using a cmdlet. In this case, Stop-Service is specifically designed to accept one service object, or many service objects, from the pipeline, and then stop them. Set-Service, Stop-Process, Move-ADObject, and Move-Mailbox are all examples of cmdlets that accept one or more input objects and then perform some task or action with each of them. You don t need to manually enumerate the objects using a construct, as I did in the VBScript example in the previous section. PowerShell knows how to work with batches of objects, and can handle them for you with a less-complex syntax.
Copyright © OnBarcode.com . All rights reserved.