Exclude Properties

by May 10, 2016

With Select-Object, you typically include the object properties you want to receive. You can do it the other way around, too, though. Here is an example that includes all properties except some unwanted ones:

#requires -Version 2

# get the latest 20 errors and warnings from the System eventlog:
Get-EventLog -LogName System -EntryType Error, Warning |
  # exclude some properties
  Select-Object -Property * -ExcludeProperty Data, ReplacementStrings, Category* |
  Out-GridView

Twitter This Tip! ReTweet this Tip!