Posted by on March 9, 2017

If you want to find all files in a particular folder with “hello” in the name, you could use the search function built into Windows Explorer, but if you want to save the list for later, or to send via email, use PowerShell instead. This cmdlet will give you every file (that you have access to list) on the C:\ drive with “hello” in the name and output the results to a csv file called C:\results.csv:

PS C:\> Get-ChildItem -filter *hello* -recurse | select directory, name | export-csv c:\results.csv -NoTypeInformation

You could output the results directly to the screen, but PowerShell will truncate the directory and file names in a way that probably won’t be very useful.

If you don’t have access to a folder, you’ll get a big, ugly, red access-denied error. To suppress that error, add “-ErrorAction SilentlyContinue” to the Get-ChildItem cmdlet. You can abbreviate that as “-EA 0”, like this:

PS C:\> Get-ChildItem -filter *hello* -recurse -EA 0 | select directory, name | export-csv c:\results.csv -NoTypeInformation
Posted in: PowerShell

Comments

Be the first to comment.

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*