🚀 PowerShell Script to Scan & Report Media/Torrent Files
- Avijit Dutta
- Sep 9
- 3 min read
🚀 PowerShell Script to Scan & Report Media/Torrent Files

📌 Introduction
Unwanted media and torrent files often pile up on domain computers — wasting space 💾, risking compliance ⚠️, and affecting bandwidth 🌐. Admins need a safe & auditable solution to scan or delete them while keeping full reports.
This article shows you how to use a PowerShell script that can:✨ Scan all fixed drives on multiple computers.✨ Delete unwanted files — or just report them safely (Dry-Run).✨ Exclude specific file types or folders.✨ Log results into an Excel 📊 report.✨ Email 📧 the report automatically to stakeholders.
❗ Problem / Challenges
⚡ Performance: Full-disk scanning is expensive.
🔑 Permissions: Need admin rights + remote execution enabled.
❌ Partial Failures: Offline hosts, locked files, or access denied.
🔒 Safety: Blind deletion is risky — admins want a dry-run mode.
📑 Audit Needs: Management requires clear reports.
🛠️ What the Script Will Do?
This PowerShell Script to Scan & Report Media/Torrent Files. Below are the steps script will perform.
Read hostnames from C:\Scripts\Computer.txt.txt.
Ping 📡 each computer for reachability.
For reachable hosts:
Scan all fixed drives.
Search for files with extensions: .mp3, .mp4, .mov, .torrent.
Exclude unwanted extensions/folders.
Either delete them 🗑️ or mark them as found (if Dry-Run enabled).
Script runs in two modes: Script has two switches/parameters:
- Dry-Run – only report files found (no deletion)
- Delete – actually delete files
Log details into an Excel file with:
🖥️ Computer Name
📂 Files Found/Deleted (wrapped text)
✅ Status
Finally, the script emails the report to 📧 abc@gmail.com with CC ➡️ xyz@gmail.com.
⚙️ Prerequisites
👨💻 Domain admin (or delegated) account with remote rights.
🔗 PowerShell Remoting (WinRM) enabled between machines.
📦 ImportExcel module (for XLSX reports) →
Install-Module -Name ImportExcel -Scope CurrentUser (falls back to CSV if unavailable)
📧 SMTP server reachable for sending reports.
🧪 Test in Dry-Run Mode first!
🛠️ Script Switches Explained
To make the script flexible and safe, we added two switches:
📝 -DryRun
- Runs in report-only mode.
- Scans and lists matching files, but does not delete anything.
- Useful for testing and verifying before running in production.
🗑️ -Delete
- Actually deletes the files found.
- Generates a report of deleted files.
- Should only be used after testing with -DryRun.
👉 You must specify either -DryRun or -Delete. If none is provided, the script will exit with a warning.
📝 Sample Report (Dry-Run Example)
📥 Download the Script
The full script named "Get-MediaFiles.ps1" is included in the zip file "Get-MediaFiles.zip". You can download it, unzip it, and use it.
🔐 Safety & Best Practices
Run in Dry-Run Mode first ✅.
Limit search scope or exclude sensitive paths (like C:\\Windows).
Keep backups before enabling delete mode.
Consider enterprise-grade DLP or File Server Resource Manager for long-term enforcement.
🎯 Conclusion
This PowerShell solution gives IT admins both power ⚡ and safety 🛡️:
Dry-Run mode for cautious reporting.
Full-delete mode for actual cleanup.
Clear, auditable Excel reports for management.
Automatic email notifications for transparency.
Perfect balance of automation + control! 💼
👉 Always run in Dry-Run mode first to validate results before switching to Delete mode. This ensures safety and avoids accidental data loss. ✅
📌 Disclaimer: Use with caution. This script is powerful and can delete files permanently. Always test in a lab environment before running in production.
☕ Found this helpful? Share it & show some love!
Tip me a coffee at 👉 paypal.me/duttaavijit #ThankYou #SupportCreators
Your small support helps fuel more free, volunteer-driven content like this. Thank you! 🙏
#PowerShell #SysAdmin #WindowsServer #Automation #ITSecurity #NetworkAdmin #FileCleanup #ExcelReport #Scripting #TechBlog #ServerManagement #CyberSecurity #ActiveDirectory #RemoteManagement #ITOps #PowerShellScript #SystemAdmin #ITAutomation #AdminTools #SecureIT #virtualgyanis



