Thursday, July 16, 2015

Configure Audit Settings for SharePoint 2013 Sites using PowerShell

Audit log feature in SharePoint helps us to analyze how SharePoint contents are being used by users or to track documents and users in accordance to compliance requirements. SharePoint 2013 audit log configuration is explained in my another post: Configuring Audit Logs Feature in SharePoint 2013 . Lets see how to enable auditing feature in SharePoint 2013 using PowerShell.

PowerShell to set SharePoint 2013 Audit Log Settings
To set SharePoint 2013 site collection audit settings using PowerShell, use this script:
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue


#Get the site collection
$Site = Get-SPSite $SiteCollURL

#Define Audit Events
$AuditLogEvents = "Delete", "Update" 

$Site.Audit.AuditFlags = $AuditLogEvents

#Set Trimming Options
$Site.TrimAuditLog = $true
$Site.AuditLogTrimmingRetention = 10

Configure Audit log Settings for All Sites in SharePoint 2013
$WebApp = Get-SPWebApplication ""
$AuditMask = [Microsoft.SharePoint.SPAuditMaskType]::Delete -bxor [Microsoft.SharePoint.SPAuditMaskType]::Update -boxr [Microsoft.SharePoint.SPAuditMaskType]::SecurityChange

$WebApp.sites | % {

$_.TrimAuditLog = $true
$_.Audit.AuditFlags = $auditmask
$_.AuditLogTrimmingRetention = 30

For all available audit masks, refer MSDN:

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...