Search for files using PowerShell
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