If you’re not using fancy file auditing software to track things, it may be challenging to find out who just filled up your drive with a bunch of data. Here’s a PowerShell script to brute force way, crawling through your network shared drive to find the largest files that were modified today. It can take a while to run if you have many folders and files to crawl through. Now you can have a list of your top 100 largest files and who owns them.
# Largest X files created today
$searchPath="H:\"
$limit = 100
$filesToday = Get-Childitem $searchPath * -Recurse -File -ErrorAction "SilentlyContinue" |
Where-Object {($_.LastWriteTime -gt (Get-Date).Date)}
$largestFiles = $filesToday | Sort-Object -Property length -Descending | Select-Object Name, @{Name="SizeInMB";Expression={$_.Length / 1MB}},@{Name="Path";Expression={$_.directory}}, @{Name="Owner";Expression={(Get-Acl $_.FullName).Owner}} -First $limit
$largestFiles
$largestFiles | Export-Csv (".\largestFilesToday_" + (Get-Date -Format "yyyy_MM_dd_hhmm") + ".csv")