Searching inside files on Windows 2008 R2

Peter Lorenzen
19/09-2011

Searching after content inside files on Windows 2008 R2 does not work. I am sure that it is possible to get it working by starting/configuring an indexing service or something like that. But when I get access to a Windows server at a customer or at hosting service I don’t really want to mess to much around.
I think it is unacceptable that such a simple thing is not always working but luckily I mostly work on Linux :-)
I think the problem is the same on Windows 7 and Windows 2008 R1/R2.

In the past I have installed miscellaneous Windows tools to be able to search, but I don’t really like this practice.

This weekend if found a solution that seems to work out of the box on the servers I currently have access to – PowerShell.

Start PowerShell with Run as administrator.
Start PowerShell

Here is an example:

# Escaped search string
$searchString = 'D:\\oracle\\product\\jrockit-jdk1.6.0_26-R28.1.4-4.0.1'
# Directory to search in
$searchLocation = 'D:\oracle\product\Middleware\*'

Get-ChildItem -Path $searchLocation -Recurse | 
SELECT-STRING -pattern $searchString

Here I search for references to JRockit in a Weblogic installation. E.g. after D:\oracle\product\jrockit-jdk1.6.0_26-R28.1.4-4.0.1 under D:\oracle\product\Middleware.

Get-ChildItem has a lot of parameters but be aware that they do not all work. I spend a couple of hours on -Exclude only to find several reports that is does not work :-(

Leave a Comment

Previous post:

Next post: