Thursday, July 11, 2024
HomeWindowsPowerShell: Quick Way to Check for a File Type on a Drive...

PowerShell: Quick Way to Check for a File Type on a Drive or Directory

Instead of performing a search on a drive or directory to see if files of a specific file type reside on it, you can save a lot of time by using PowerShell. It will come back with a True or False response in a matter of seconds instead of having to wait for the search to complete. This comes in handy if you are trying to analyze what file types are being stored on your server (for example, you want to make sure no one is stashing their MP3 collection on it!)

1. Open PowerShell.

2. You will use the test-path cmdlet, the directory or drive path, and a wildcard expression, so if we were checking the Data directory on the C Drive for MP3 files, it would look like this:test-path C:\Data\*.mp3

3. Press Enter.

4. You will receive either a True or False response.

Rob Rogers
Rob Rogers
Once a prolific author here on Tech-Recipes, Rob has moved on to greener pastures.


Please enter your comment!
Please enter your name here

Most Popular


Recent Comments

error: Content is protected !!