3

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?

0

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:

https://docs.microsoft.com/en-us/dotnet/api/microsoft.sharepoint.spauditmasktype?redirectedfrom=MSDN&view=sharepoint-server

  • hi specifically i need the audit log for User level actions.For example one user is removed from site I want the Audit report which user is removed and owner name who is Removed. For this details i have to write power-shell script.And site settings-- > Audit log reports--> where we can see the user related report. – Elina Sep 4 '18 at 9:24
1

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

Read more: http://www.sharepointdiary.com/2015/07/enable-audit-logs-in-sharepoint-2013-using-powershell.html#ixzz5PfZOZLKE

this article explain the auditing in detail: http://www.sharepointdiary.com/2015/06/configuring-audit-logs-feature-in-sharepoint-2013.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.