How to Enable all the SharePoint site collection Audit setting using power shell script.
Can you Please give me some example Script to enable the Audit settings?
Run the following PowerShell in windows PowerShell ISE:
Add-PSSnapin Microsoft.SharePoint.Powershell
$webapp = Get-SPWebApplication "http://sp"
$auditmask = [Microsoft.SharePoint.SPAuditMaskType]::Delete -bxor [Microsoft.SharePoint.SPAuditMaskType]::Update -bxor [Microsoft.SharePoint.SPAuditMaskType]::SecurityChange
$webapp.sites | % {
$_.TrimAuditLog = $true
$_.Audit.AuditFlags = $auditmask
$_.Audit.Update()
$_.AuditLogTrimmingRetention = 30
}
SPAuditMaskType Enum:
You can try following powershell script:
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
$SiteCollURL="http://intranet.crescent.com"
#Get the site collection
$Site = Get-SPSite $SiteCollURL
#Define Audit Events
$AuditLogEvents = "Delete", "Update"
$Site.Audit.AuditFlags = $AuditLogEvents
$Site.Audit.Update()
#Set Trimming Options
$Site.TrimAuditLog = $true
$Site.AuditLogTrimmingRetention = 10
this article explain the auditing in detail: http://www.sharepointdiary.com/2015/06/configuring-audit-logs-feature-in-sharepoint-2013.html