O'Reilly logo

Pro Windows PowerShell by Hristo Deshev

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

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:

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