Recursively search for a string in all *.txt
files:
gci . *.txt -Recurse | select-string -pattern "search-text"
Recursively search for a string in all *.h
and *.cpp
files:
gci . -Include ( "*.h", "*.cpp" ) -Recurse | select-string -pattern "search-text"
Recursively search for all app.config
files and print full path:
gci . -Include ( "app.config" ) -Recurse | % { $_.FullName }
Compute the filesize sum of all of the TXT and XML files in the current directory:
PS:>gci *.txt,*.xml | measure-object -property Length -sum
Look up Powershell Environment Variables:
PS:> ${env:Path}.IndexOf("DoesExist") 26 PS:> ${env:Path}.IndexOf("DoesNotExist") -1