Search for specific file extension (Powershell)

*** THIS SCRIPT IS PROVIDED WITHOUT WARRANTY, USE AT YOUR OWN RISK ***

This script will allow you to search a directory and all its subfolders for a file extension of your choosing. The output includes the file path, last write time and the size in MBs.

I have used this to search a share for old mp3 files or avi files in order to clean-up our SAN device. I suppose you could also sort it by the lastwritetime so if you had a file that was last written to in 1998 one would assuming it’s probably ok to delete it or archive it.

You can search the local (C:\), any mapped drive (Z:\) or use it to search a SAN or NAS using the UNC path (\\fileshare\share or \\192.168.1.1\share)

Tested on Windows Server 2K3, Windows Server 2K8, Windows Server 2K8 R2, Windows 7 x64, Windows Vista.

 

1 Comment

Leave a Reply