I have written the script below which will generate a CSV for the 20 oldest files and 20 biggest files that belong to a particular user. It works, but as you can imagine, on a file-server with over 3 million files, it takes a long time to run. The Quota Entries tool can identify the owner of a file much more quickly when deleting a quota entry, I'm wondering if there is an index or something that I might be able to tap into, or if there is any other way you can think to make this run more efficiently. Obviously using FSRM would be preferred, but it will take months to get that approved and installed (if at all), so I really need a stop-gap solution.
Import-Module activedirectory $username = Read-Host "Which user would you like to run the report for?" $usersid = Get-ADUser -Identity $username -Properties * | foreach {$_.sid} | foreach {$_.value} $filepaths = cmd /c dir "E:\Data" /b /s /a-d | foreach {get-acl $_ | where {$_.sddl -match "$usersid"}} $filesizes = $filepaths | foreach {$_.path} | foreach {Get-item $_} $biggestfiles = $filesizes | sort length -Descending | select -first 20 $biggestfiles | select @{Name="FileSize(MB)"; Expression={($_.length/1mb -as [INT])}}, @{Name="FilePath"; Expression={$_.fullname}}, @{Name="LastWriteTime"; Expression={$_.lastwritetime}}, @{Name="LastAccessTime"; Expression={$_.LastAccessTime}} | Export-Csv bigfiles.csv -NoTypeInformation $oldestfiles = $filesizes | sort lastwritetime -descending | select -last 20 $oldestfiles | select @{Name="LastWriteTime"; Expression={$_.lastwritetime}}, @{Name="FilePath"; Expression={$_.fullname}}, @{Name="LastAccessTime"; Expression={$_.LastAccessTime}}, @{Name="FileSize(MB)"; Expression={($_.length/1mb -as [INT])}} | Export-Csv oldfiles.csv -NoTypeInformation