# Audit settings

This week I was trying to make some PowerShell scripts to set the auditing in SharePoint. This can be done very easy with the GUI, but I had to set this on a few thousand sites. With the GUI you can go to the site collection and then settings. Under ‘site collection administration’ you find ‘Site collection audit settings’

Just select the options you want and you’re all set to use auditing.

So this I good if you need a few sites, but not a few thousand, so I went to PowerShell. This is fairly easy to set up with a few lines of PowerShell $sp_sitecol = Get-SPSite -Identity http://in.sp2013dev.com Write-Host “Turning Audit Log Trimming on” -ForegroundColor Green$sp_sitecol.TrimAuditLog = $true$sp_sitecol.AuditLogTrimmingRetention = 30 [Microsoft.Office.RecordsManagement.Reporting.AuditLogTrimmingReportCallout]::SetAuditReportStorageLocation($sp_sitecol, “/AuditLog”)$sp_audit = $sp_sitecol.Audit$sp_audit.AuditFlags = “View, Update, Undelete, Copy, Move, SecurityChange” \$sp_audit.Update()

Just repeat this for all the site collection you want. All the options for the auditFlags can be found on MSDN