O'Reilly logo

Learn PowerShell Toolmaking in a Month of Lunches by Don Jones and Jeffrey Hicks

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

20.4. Working with nested objects

Whether you create your own object hierarchies or merely have some that were output from existing commands, you need to know how to work with them effectively. There are four main techniques:

  • Use Select-Object to expand a property that contains subobjects, enabling you to see the individual subobjects.
  • Use Format-Custom to expand the entire object hierarchy.
  • Use a ForEach loop.
  • Use PowerShell’s array syntax to work with individual subobjects.

To illustrate each of these techniques, we’ll use Get-Service. The objects produced by this command have several properties that are child objects (which we’ve also been calling nested objects or subobjects). Those properties include ServicesDependedOn (also known ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required