2

I am seeking for Server Object model to Activate and deactivate the SharePoint Audit Feature.

Can any one help me how can I achieve this?

2

Adjust as needed.

$webapp = Get-SPWebApplication http://webAppUrl
$auditmask = [Microsoft.SharePoint.SPAuditMaskType]::View -bxor [Microsoft.SharePoint.SPAuditMaskType]::Update `
    -bxor [Microsoft.SharePoint.SPAuditMaskType]::Delete -bxor [Microsoft.SharePoint.SPAuditMaskType]::Search

$webapp.sites | % {

$_.TrimAuditLog = $true
$_.Audit.AuditFlags = $auditmask
$_.Audit.Update()
$_.AuditLogTrimmingRetention = 30
}
1

You can try the following code

SPAudit audit = siteCollection.Audit;
audit.AuditFlags =
  SPAuditMaskType.SecurityChange |
  SPAuditMaskType.SchemaChange;
audit.Update(); 

For more information, please refer to the following link:

https://www.codeproject.com/articles/431342/auditing-a-built-in-feature-of-sharepoint https://gallery.technet.microsoft.com/office/enable-auditing-sharepoint-b2bba327

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.