Chapter 8. Objects: data by another name

We’re going to do something a little different in this chapter. PowerShell’s use of objects can be one of its most confusing elements, but at the same time it’s also one of the shell’s most critical concepts, affecting everything you do in the shell. We’ve tried various explanations over the years, and we’ve settled on a couple that each work well for distinctly different audiences. If you have programming experience and are comfortable with the concept of objects, we want you to skip to section 8.2. If you don’t have a programming background, and haven’t programmed or scripted with objects before, start with section 8.1 and read straight through the chapter.

8.1. What are objects?

Take a second to run Get-Process in PowerShell. You should see a table with several columns, but those columns barely scratch the surface of the wealth of information available about processes. Each process object also has a machine name, a main window handle, a maximum working set size, an exit code and time, processor affinity information, and a great deal more. You’ll find more than 60 pieces of information associated with a process. Why does PowerShell show so few of them?

8.2. Understanding why PowerShell uses objects

8.3. Discovering objects: Get-Member

8.4. Using object attributes, or properties

8.5. Using object actions, or methods

8.6. Sorting objects

8.7. Selecting the properties you want

8.8. Objects until the end

8.9. Common points of confusion

8.10. Lab

8.11. Lab answers