How it works...
In the first section, we added members to the objects within a certain variable. This was a command-line-prompt-style extension to the Creating a custom object from a returned object recipe, which was, by all means, a little more efficient in the context. However, the changes we made to the object remained only while the $FilesWithAge variable was valid. The object returned by Get-ChildItem was not modified at all.
There is an important point to note here: $this. We have come across the automatic variable, $_ (or $PSItem, after PowerShell V3) when dealing with objects passed through the pipeline; this variable holds the current instance of the object in the pipeline. However, when we have to perform an object extension, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access