Chapter 03Lesson 01~85 minutes

Objects Instead of Lines of Text

Build an intuitive mental model of PowerShell objects, types, properties, methods, collections, and formatting so you can work with data directly instead of parsing what happens to be printed on screen.

BeginnerObjectsPipeline

Learning objectives

By the end of this lesson

  • Explain why parsing formatted screen text is fragile and how object-oriented output avoids that class of problem.
  • Define object, type, property, method, and collection in ordinary language before connecting them to .NET terminology.
  • Use Get-Process to prove that the columns displayed on screen are only a view of a richer underlying object.
  • Retrieve the same underlying property in raw, selected, and formatted forms without confusing display with data.
  • Use GetType() only after first identifying the object through observable properties and behavior.

1. The fragile approach: parse whatever the screen printed

Many command-line tools communicate by printing lines of text. That model is useful, but it can make automation depend on column spacing, localized labels, units, or formatting choices that were designed for humans rather than machines. A script that slices “the third column” is really depending on a display layout.

PowerShell tries to reduce that fragility. Most cmdlets emit objects: structured values whose named fields remain available even when the screen chooses to show only a few of them.

Get-Process -Id $PID | Format-Table Id, ProcessName, CPU

That table is useful to a person, but it is not the process itself. The process object existed before the formatter decided which columns to show. If a later command needs the process identifier, the robust approach is to ask for the Id property—not parse characters from the rendered table.

$current = Get-Process -Id $PID
$current.Id
$current.ProcessName
Mental shift

In PowerShell, ask “what object is flowing?” and “which property do I need?” before asking “what text is visible?”

2. Object, type, property, method, collection—in ordinary language

An object is one structured value that represents something: a process, file, date, network result, deployment record, or configuration item. It can carry both data and behavior.

TermBeginner mental modelExample
ObjectOne structured value representing a thing.The PowerShell process hosting your current session.
TypeThe blueprint/category that describes what kind of object it is.A process object is typically based on System.Diagnostics.Process.
PropertyA named piece of data stored or exposed by the object.Id, ProcessName, StartTime.
MethodAn action exposed by the object.A process object has methods such as Refresh().
CollectionA container holding multiple values/objects.The result of Get-Process when many processes are returned.

PowerShell is built on .NET, so many of the underlying types are .NET classes. You do not need prior C# knowledge to use them. Start with the practical questions: what properties does this object expose, what type is it, and what commands accept it?

3. Properties are named data, not screen columns

Run the following against the current PowerShell process. The first command lets PowerShell choose its normal display. The second accesses named properties explicitly.

$current = Get-Process -Id $PID
$current

$current | Select-Object Id, ProcessName, StartTime, WorkingSet64

Your default process display probably does not include every property above. That does not mean those properties are missing. It means the formatting system selected a smaller human-friendly view.

$current.Id
$current.WorkingSet64
[math]::Round($current.WorkingSet64 / 1MB, 2)

Notice the difference between the raw byte count in WorkingSet64 and any human-friendly memory column PowerShell may show by default. Formatting can convert units or abbreviate labels while the underlying property stays machine-usable.

4. Methods are behavior attached to an object

Some objects expose methods—operations that belong to that object. For example, a process object has a Refresh() method that asks the object to refresh its cached process information.

$current = Get-Process -Id $PID
$current.Refresh()
$current.Id

For day-to-day automation, prefer a PowerShell cmdlet when one clearly expresses the operation because cmdlets usually provide consistent parameters, help, error behavior, and pipeline support. Methods remain important because they reveal that PowerShell objects are not passive rows of text.

5. One object versus many objects

A command can emit one object, many objects, or no objects. When many process objects are returned, PowerShell can treat the result as a collection while still allowing the pipeline to enumerate its individual elements.

$processes = Get-Process
$processes.Count
$processes | Select-Object -First 3 Id, ProcessName

The collection has its own characteristics, and each process inside it has process characteristics. This distinction becomes important in the next lesson when we compare inspecting the collection itself with inspecting the elements that flow through the pipeline.

6. The default display is a view over underlying data

PowerShell has a formatting subsystem that knows preferred views for many common object types. When an object reaches the host without being consumed by another data-processing command, PowerShell chooses a presentation such as a table or list.

$current = Get-Process -Id $PID
$current | Format-List Id, ProcessName, StartTime, WorkingSet64
$current | Format-Table Id, ProcessName, WorkingSet64

Both commands started with the same process object. The display changed; the source object did not. That separation is one of the most important ideas in this entire course: data first, presentation last. Lesson 05 will explain why formatting commands normally belong at the end of a pipeline.

7. Now connect the mental model to the actual type

Once you understand that the value is a structured object with named properties and methods, GetType() becomes meaningful rather than mysterious.

$current = Get-Process -Id $PID
$current.GetType().FullName
System.Diagnostics.Process

The exact type name above is the standard type returned by Get-Process. The name tells you that the object is a .NET process object. PowerShell can add or adapt members around .NET objects; Lesson 02 introduces that Extended Type System concept without requiring you to become a .NET developer.

8. Retrieve the same property in several display forms

Use one property—Id—and observe how presentation changes around the same underlying value.

$current = Get-Process -Id $PID

# Raw scalar property value
$current.Id

# A new object containing the selected property
$current | Select-Object Id

# A human-oriented table view
$current | Format-Table Id

# A human-oriented list view
$current | Format-List Id

The raw expression returns the property value itself. Select-Object creates a projected object with selected properties. Format-Table and Format-List create formatting instructions for human display. These are not interchangeable operations.

9. Why object output matters in DevOps

DevOps automation constantly composes tools: inventory, health checks, deployment decisions, cloud resources, services, files, CI metadata, and API responses. Structured objects let you filter on an actual Boolean, sort a real number, group by a named field, or export selected properties without guessing how a table is spaced.

The result is not that text disappears—native tools, logs, configuration files, and network protocols still use text heavily. The advantage is that inside a PowerShell workflow you can preserve structure for as long as possible and serialize or format only when you intentionally cross a boundary.

10. Lab: prove that display is not the object

This lab is read-only. Use only the process hosting your current PowerShell session so the result exists on Windows, Linux, and macOS.

$p = Get-Process -Id $PID

# 1. Let PowerShell choose the default display.
$p

# 2. Read the property directly.
$p.Id
$p.ProcessName

# 3. Project selected properties.
$p | Select-Object Id, ProcessName, WorkingSet64

# 4. Render the same source object in two human views.
$p | Format-Table Id, ProcessName, WorkingSet64
$p | Format-List Id, ProcessName, WorkingSet64

# 5. Inspect the underlying type only after observing behavior.
$p.GetType().FullName

Write down which commands returned raw data, which created a selected object, and which only changed the presentation. If the value of Id remains the same across the forms, you have demonstrated the distinction between object data and rendering.

Verification checklist

11. Common misconceptions

“The columns I see are the object.” They are a selected display. The object can expose many more properties and methods.

“Everything PowerShell prints is a string.” The host renders objects as text for humans, but the pipeline can carry structured objects before rendering.

“A property name is just a column header.” A property is addressable data on the object and can be used for filtering, sorting, grouping, calculation, and serialization.

“Methods are always the best way to automate an object.” Use methods when appropriate, but prefer well-designed cmdlets when they provide the operation because they integrate with PowerShell conventions.

12. Knowledge check

Question 1. Why is parsing the third printed column of Get-Process fragile?

Question 2. What is a property?

Question 3. What changes when you pipe the same object to Format-Table instead of Format-List?

Question 4. What does a collection represent?

Question 5. Why did this lesson delay GetType() until after properties and methods?

13. Summary

PowerShell’s defining composition model is based on structured objects rather than only visible lines of text. Objects have types, properties, and methods; multiple objects form collections; and the formatting system decides how those values appear to a human. Keep data structured as long as possible. Read named properties instead of parsing display text, and treat formatting as presentation rather than the object itself.

14. Further reading

Next lesson

Use Get-Member as an object microscope

Now that the object mental model is clear, Lesson 02 teaches how to inspect unfamiliar objects, interpret member types, compare data selection with display, and understand PowerShell’s Extended Type System at a practical level.

Keep the academy open

Support free, practical DevOps education.

Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0 Send only Ethereum/ERC-20 compatible assets to this address.