Search Everything with PowerShell

Image Description

Daily PowerShell #22

Scripting Daily PowerShell

November 7, 2021

quote Discuss this Article

Everything is a Windows file system indexer that makes search very fast. This post uses the PSEverything module to search Everything.

Installation

First, you’ll need to install Everything. Everything is installed as a Windows service and will index all the files and folders on the system. According to the to the FAQ, indexing 1 million files takes about 1 minute.

You can download Everything here.

Once you have Everything installed, you can install PSEverything. It’s a module for interacting with the Everything indexer.

Install-Module PSEverything

Searching for File Extensions

You can easily search for file extension using the -Extension parameter. A list of file paths will be returned.

Search-Everything -Extension cs 

You can measure the output by use Measure-Object.

PS C:\Users\adamr> Search-Everything -Extension cs | Measure-Object

Count             : 12319
Average           :
Sum               :
Maximum           :
Minimum           :
StandardDeviation :
Property          :

You can see the searching everything is pretty quick. Return 12k files took about 140 milliseconds.

PS C:\Users\adamr> Measure-Command { Search-Everything -Extension cs  }

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 140
Ticks             : 1404572
TotalDays         : 1.62566203703704E-06
TotalHours        : 3.90158888888889E-05
TotalMinutes      : 0.00234095333333333
TotalSeconds      : 0.1404572
TotalMilliseconds : 140.4572

Search with a Filter

You can use the -Filter cmdlet to search using a wildcard filter.

Search-Everything -Filter log*.txt

Searching my entire computer using this filter is extremely fast.

PS C:\Users\adamr> Measure-Command { Search-Everything -Filter log*.txt }

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 57
Ticks             : 574047
TotalDays         : 6.6440625E-07
TotalHours        : 1.594575E-05
TotalMinutes      : 0.000956745
TotalSeconds      : 0.0574047
TotalMilliseconds : 57.4047

Excluding Paths

You can exclude paths with the -FolderExclude parameter. This example searches for the string driver* throughout my system but excludes the windows directory.

Search-Everything -FolderExclude C:\Windows -Filter driver*