Extracting the value from a single property in VB.NET

Print Data Matrix ECC200 in VB.NET Extracting the value from a single property

Extracting the value from a single property
Painting Data Matrix In VB.NET
Using Barcode encoder for .NET framework Control to generate, create Data Matrix 2d barcode image in .NET framework applications.
www.OnBarcode.com
Data Matrix ECC200 Decoder In Visual Basic .NET
Using Barcode scanner for VS .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
Earlier in this chapter, I showed you an example of using parentheses to execute GetContent, feeding its output to the parameter of another cmdlet:
Code128 Creator In VB.NET
Using Barcode encoder for .NET Control to generate, create Code 128A image in .NET applications.
www.OnBarcode.com
Creating EAN / UCC - 13 In Visual Basic .NET
Using Barcode maker for VS .NET Control to generate, create UCC - 12 image in Visual Studio .NET applications.
www.OnBarcode.com
Get-Service -computerName (Get-Content names.txt)
Barcode Generation In VB.NET
Using Barcode creation for .NET Control to generate, create Barcode image in .NET framework applications.
www.OnBarcode.com
Making UPC-A Supplement 2 In Visual Basic .NET
Using Barcode generator for Visual Studio .NET Control to generate, create UPC-A Supplement 2 image in .NET framework applications.
www.OnBarcode.com
Rather than getting your computer names from a static text file, you might well want to query them from Active Directory. With the ActiveDirectory module (which hopefully you still have loaded from the previous examples in this chapter), you could query all of your domain controllers:
Code 3 Of 9 Generator In Visual Basic .NET
Using Barcode generation for .NET framework Control to generate, create Code 39 image in .NET framework applications.
www.OnBarcode.com
Creating MSI Plessey In Visual Basic .NET
Using Barcode maker for VS .NET Control to generate, create MSI Plessey image in .NET applications.
www.OnBarcode.com
get-adcomputer -filter * -searchbase "ou=domain controllers, dc=company,dc=pri"
DataMatrix Drawer In None
Using Barcode creation for Microsoft Excel Control to generate, create Data Matrix 2d barcode image in Microsoft Excel applications.
www.OnBarcode.com
Encode Data Matrix ECC200 In Visual Studio .NET
Using Barcode printer for ASP.NET Control to generate, create Data Matrix 2d barcode image in ASP.NET applications.
www.OnBarcode.com
Could you use the same parentheses trick For example, would this work
QR Code JIS X 0510 Recognizer In None
Using Barcode scanner for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Making EAN-13 In Visual C#
Using Barcode generation for VS .NET Control to generate, create European Article Number 13 image in VS .NET applications.
www.OnBarcode.com
Get-Service -computerName (Get-ADComputer -filter * -searchBase "ou=domain controllers,dc=company,dc=pri")
ANSI/AIM Code 39 Generator In None
Using Barcode creation for Font Control to generate, create Code 39 Full ASCII image in Font applications.
www.OnBarcode.com
Draw Data Matrix In Objective-C
Using Barcode creator for iPhone Control to generate, create Data Matrix 2d barcode image in iPhone applications.
www.OnBarcode.com
Sadly, it won t. Look at the help for Get-Service, and you ll see that the -computerName parameter expects String values. Run this instead:
Encoding USS Code 39 In Objective-C
Using Barcode creator for iPad Control to generate, create Code39 image in iPad applications.
www.OnBarcode.com
QR Code Creation In Java
Using Barcode encoder for BIRT Control to generate, create QR Code JIS X 0510 image in Eclipse BIRT applications.
www.OnBarcode.com
get-adcomputer -filter * -searchbase "ou=domain controllers, dc=company,dc=pri" | gm
UPC-A Recognizer In Java
Using Barcode reader for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Encode Data Matrix In None
Using Barcode creator for Office Excel Control to generate, create Data Matrix image in Office Excel applications.
www.OnBarcode.com
Get-Member reveals that Get-ADComputer is producing objects of the type ADComputer. Those aren t String objects, so -computerName won t know what to do with them. The ADComputer objects do have a Name property, however. What we need to do is somehow extract just the values of the objects Name properties, and feed those values, which are computer names, to the -ComputerName parameter. Once again, the Select-Object cmdlet can rescue us. It includes an -expandProperty parameter, which accepts a property name. It will take that property and extract its values, and return just those values as the output of Select-Object. Try this:
EAN13 Drawer In Java
Using Barcode drawer for Java Control to generate, create GTIN - 13 image in Java applications.
www.OnBarcode.com
Read USS Code 39 In Java
Using Barcode reader for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
get-adcomputer -filter * -searchbase "ou=domain controllers, dc=company,dc=pri" | Select-Object -expand name
You should get a simple list of computer names. Those can be fed to the -computerName parameter of Get-Service (or any other cmdlet that has a -computerName parameter):
Get-Service -computerName (get-adcomputer -filter * -searchbase "ou=domain controllers,dc=company,dc=pri" | Select-Object -expand name)
Again, this is a cool trick that makes it possible to combine an even wider variety of commands with each other, saving you typing and making PowerShell do more of the work.
Once again, we ve covered a lot of important concepts in a short amount of time. The best way to cement your new knowledge is to put it to immediate use. I recommend doing the following tasks in order, because they build on each other to help remind you of what you ve learned and to help you find practical ways to use that knowledge. Complete these tasks:
Would the following command work to retrieve a list of installed hotfixes from all domain controllers in the specified domain Why or why not Write out an explanation, similar to the ones I provided earlier in this chapter.
Get-Hotfix -computerName (get-adcomputer -filter * -searchbase "ou=domain controllers,dc=company,dc=pri" | Select-Object -expand name)
The pipeline, deeper
Would this alternative command work to retrieve the list of hotfixes from the same computers Why or why not Write out an explanation, similar to the ones I provided earlier in this chapter.
get-adcomputer -filter * -searchbase "ou=domain controllers,dc=company,dc=pri" | Get-HotFix
Would this third version of the command work to retrieve the list of hotfixes from the domain controllers Why or why not Write out an explanation, similar to the ones I provided earlier in this chapter.
get-adcomputer -filter * -searchbase "ou=domain controllers,dc=company,dc=pri" | Select-Object @{l='computername';e={$_.name}} | Get-Hotfix
Write a command that uses pipeline parameter binding to retrieve a list of running processes from every computer in an AD domain. Don t use parentheses. Write a command that retrieves a list of installed services from every computer in an AD domain. Don t use pipeline input; instead use a parenthetical command (a command in parentheses). Sometimes Microsoft forgets to add pipeline parameter binding to a cmdlet. For example, would the following command work to retrieve information from every domain controller in the domain Write out an explanation, similar to the ones I provided earlier in this chapter.
get-adcomputer -filter * -searchbase "ou=domain controllers,dc=company,dc=pri" | Select-Object @{l='computername';e={$_.name}} | Get-WmiObject -class Win32_BIOS
Copyright © OnBarcode.com . All rights reserved.