I have been managing a modest SBS 2003 server for several years. Our network policy is setup to store user profiles and "My Documents" folder on the server. Recently the server disk has been getting full, and running WinDirStat every few weeks has allowed me to tackle the problem by identifying large files and taking care of them individually.
Is there a monitoring tool that proactively looks for large files (created recently) and has a report/notification system built in to ping me when large files are created (maybe >100mb?)
Or is there a program/script to filter files and folders in such a way that it orders them in a manner that puts heavy weight on file creation time VS file size?
I have searched around and can't find a windows tool that does the above.
File Server Resource Manager will do what you're looking for.
How to install on SBS 2003 R2 here.
You would want to create a File Screen Template
and go from there:
This can also be done with a Powershell script, which should work for you as well:
#------------------------------------------------------------
# LargeFiles.CSV
# Server = Server name without any slashes. Full UNC name can be used
# Path = Can be any path but if you are using the administrative shares be
# sure to use the "$"
# Example:) L$\share\path\folder\etc or L$
#------------------------------------------------------------
#Get-ChildItem L:\ -Recurse | Where-Object {$_.Length -gt 10GB} | Select-Object @{Name="GB";Expression={$_.Length / 1GB}},Name
$FromAddress = "FromEmailAddress"
$ToAddress = "ToEmailAddress"
$MessageSubject = "Large Files Found"
$SendingServer = "SMTPServer.domain.local"
function CreateLargeFilesCSV
{
Write-Host "--------------------------------------------------------`r" -foreground yellow
Write-Host "The LargeFiles.csv file did not exist. This was created for you.`r" -foreground yellow
Write-Host "You must now populate this file with the proper information,`r" -foreground yellow
Write-Host "See files for more details.`r" -foreground yellow
New-Item LargeFiles.csv -type file
Add-Content LargeFiles.csv "Server,Path"
Add-Content LargeFiles.csv "SQL1,I$"
Add-Content LargeFiles.csv "SQL1,K$\Sharename\folder\etc"
}
function CheckSize
{
foreach ($result in $results)
{
$strServer = $result.Server
$strServer = "\\$strServer\"
$strPath = $result.Path
$strPath = "$strPath"
$strMaxFileSize = $result.MaxFileSize
Get-ChildItem $strServer$strPath -Recurse | Where-Object {$_.Length -gt 10GB} | Select-Object Name,@{Name="Size(GB)";Expression={"{0:N2}" -f ($_.Length/1GB)}},@{Name="Server";Expression={$strServer}},@{Name="Path";Expression={$strPath}} | ConvertTO-HTML | Format-Table -AutoSize | Out-File Results.txt -append
}
}
if (Test-Path LargeFiles.csv)
{
$Results = Import-CSV LargeFiles.csv | Select Server,Path
CheckSize
}
else
{
CreateLargeFilesCSV
}
$Answer = Get-Content Results.txt | Select-String "</colgroup>" -quiet
If ($Answer -eq $true)
{
Write-Host "Found some large files"
$MessageBody = (Get-Content Results.txt | out-string)
$MessageBody = "Found some large files. Below is a list of these files`n$MessageBody"
Remove-Item Results.txt
###Create the mail message
$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $ToAddress, $MessageSubject, $MessageBody
$SMTPMessage.IsBodyHTML = $true
###Send the message
$SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer
$SMTPClient.Send($SMTPMessage)
}
Else
{
Write-Host "Nothing to send"
Remove-Item Results.txt
}
- See more at: http://it-erate.com/hunting-alerting-large-files-powershell/#sthash.XI56yxdl.dpuf
External links referenced by this document: