3.5. Adding or Deleting Properties Using Select-Object

Select-Object has also been named after a related operation from the databases world—the SELECT clause that defines the columns that are returned in our query result set. While Where-Object allows us to select a subset of a collection's items, analogous to selecting rows from a table, Select-Object does the same for properties, similar to manipulating a table's columns. The Select-Object cmdlet allows us to remove properties from the resulting objects or even add new ones that will be calculated on the fly.

At the very minimum, Select-Object asks for a list of properties that will be returned. Here is how to get just the names and last access times for the files in the current folder:

Get Pro Windows PowerShell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.