Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
SharePoint 2013 administration is VERY PowerShell centric... and yet we're still learning ways to perform actions that were a single command in the previous STSADM tool. Well, one thing that was easy to do in a prior version was trim SharePoint auditing data from the SharePoint content databases. For customers that have unintentionally allowed the amount of auditing data to grow significantly, forcing a mass trim command can be a very powerful capability. Interestingly, I couldn't find any good, clear, simple examples on how to do this en mass. So, here you go. It's clearly not complicated but took a small amount of digging. Hopefully you find it useful as a good starting point.
# Begin Example Script
Add-PSSnapin Microsoft.SharePoint.PowerShell
$oldestEntryDate = Get-Date "January 1, 2014"
$sitesToClean = get-spsite -ContentDatabase WSS_Content
$sitesToClean | ForEach-Object { $_.Audit.DeleteEntries($oldestEntryDate) }
# End Example Script