SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Windows Search Enable Your Script Files

At the July 8th Tampa PowerShell User Group meeting, Ed Wilson (blog|twitter) gave a presentation on “PowerShell Best Practices.” One of the tips Ed mentioned is enabling Windows Search to index the content of PowerShell ps1 files. Although I’ve used grep or in PowerShell, Select-String to find strings within script files there are advantages to being able to search  in Windows Explorer and yes its OK to use the GUI sometimes.

If like me you haven’t used Windows Search features in years, you’re probably wondering how to you set the indexing options. So I’ve provided a step-by-step guide…

Changing Indexing Options

In Windows 7 or Vista on the Start Menu in the Search Programs type Indexing options

Select Indexing Options located under Control Panel


Under Indexing Options select Advanced


Next select the File Types tab

Select the ps1 file extension and with the file extension selected, choose Index Properties and File Content

Click OK and Close


Window will start indexing your ps1 file immediately. You will then be able to search the content of PowerShell scripts within Windows Explorer. Here’s an example searching for the string invoke-coalesce across all PowerShell scripts:


Although grep and select-string are more full-featured (for example the matching line and line numbers can be returned), Windows Search is fine for simple searches. You may want to enable content search for other types of script files such as .sql files also

Chad Miller

Chad Miller is a Senior Manager of Database Administration at Raymond James Financial. Chad has worked with Microsoft SQL Server since 1999 and has been automating administration tasks using Windows Powershell since 2007. Chad is the Project Coordinator/Developer of the Powershell-based Codeplex project SQL Server PowerShell Extensions (SQLPSX). Chad leads the Tampa Powershell User Group and is a frequent speaker at users groups, SQL Saturdays and Code Camps.


No comments.

Leave a Comment

Please register or log in to leave a comment.