Wednesday, February 1, 2012

Searching for text files using Powershell

Below, one can admire the simplicity, power, and flexibility of Powershell.

Here are two ways of searching for all textfiles in your C Drive.

  • Get-Childitem C:\ -recurse -force | Foreach { IF ($_.extension -eq ".txt") { $_.name } }

  • Get-ChildItem C:\ -recurse -force | Where { $_.extension -eq ".txt" } | select $_.name

No comments: