Search for files using PowerShell

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

To search for files using Windows PowerShell is pretty easy.

PS C:\> CD $Env:WinDir
PS C:\Windows>Get-ChildItem -Recurse | Where-Object {$_.Name -match "notepad.exe"}

this should result in something like.

Directory: Microsoft.PowerShell.Core\FileSystem::C:\Windows

Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 21.01.2008 03:46 169472 notepad.exe

to supress any access denied errors, you can add the -errorAction “SilentlyContinue” instruction / parameter.

PS C:\> CD $Env:WinDir
PS C:\Windows> Get-ChildItem -Recurse -errorAction "SilentlyContinue" | Where-Object {$_.Name -match "notepad.exe"}

and if you want to have the result exported to an Excel CSV file, you could simply add Export-Csv c:\temp\output.csv

PS C:\> CD $Env:WinDir
PS C:\Windows> Get-ChildItem -Recurse -errorAction "SilentlyContinue" | Where-Object {$_.Name -match "notepad.exe"} | Export-Csv c:\temp\output.csv

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.