MOSS 2013 Powershell script to trim or delete audit data logs

reference- http://iedaddy.com/2012/12/sharepointuse-powershell-to-delete-audit-data-from-farm/
$site = get-spsite -webapplication “https://abc.com/”

Write-host ‘Deleting audit data for site: ‘ $site.URL
$i = -1610
do {
Write-Host $site.URL ‘ – Delete day ‘ $i ‘ : ‘ ([System.DateTime]::Now.ToLocalTime().AddDays($i))
$site.audit.deleteentries([System.DateTime]::Now.ToLocalTime().AddDays($i))
$site.audit.update()
$i++
}
while ($i -le 1)

$site.Dispose()

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s