Filter PowerShell Results Fast and Text-Based

Share |

Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Powershell Plus

13 Free SQL Tools from Idera

Free Ebook: Mastering Powershell


Take a look at this simple filter called grep:

filter grep($keyword) { if ( ($_ | Out-String) -like "*$keyword*") { $_ } }

And here are some samples showing how easy it is to filter results using plain text keywords:

PS > Get-Service | grep running
PS > Dir $env:windir | grep .exe
PS > dir $env:windir | grep 14.07.2009
PS > Get-Alias | grep child

As you can see, while the filtering is based on simple plain text keywords, the results are still rich objects!


Twitter This Tip! ReTweet this Tip!

Posted Mar 25 2011, 08:00 AM by ps1


draugasvd wrote re: Filter PowerShell Results Fast and Text-Based
on 03-25-2011 4:12 PM

this good one!

Copyright 2012 All rights reserved.