Export (0) Print
Expand All

Audit.MaximumFileSizeUnit Property

Gets or sets the maximum file size unit that an audit is allowed to reach.

Namespace:  Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

[SfcPropertyAttribute(SfcPropertyFlags.None|SfcPropertyFlags.Standalone|SfcPropertyFlags.Matrix)]
public AuditFileSizeUnit MaximumFileSizeUnit { get; set; }

Property Value

Type: Microsoft.SqlServer.Management.Smo.AuditFileSizeUnit
An AuditFileSizeUnit value specifying the type of the maximum audit file size.

The MaximumFileSizeUnit property specifies whether the maximum size of the audit log file can be measured in megabytes, gigabytes, or terabytes. When the audit is created, it defaults to the megabytes setting.

The following code example shows how to set the maximum file type size of the audit log file to gigabytes.

C#

using System;
using Microsoft.SqlServer.Management.Smo;

namespace samples
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create the audit 
            Server dbServer = new Server("(local)");
            Audit dbAudit = new Audit(dbServer, "Test Audit");
            dbAudit.DestinationType = AuditDestinationType.File;
            dbAudit.FilePath = "C:\\AuditDirectory";
            dbAudit.Create();

            //Set the audit file size unit
            dbAudit.MaximumFileSizeUnit = AuditFileSizeUnit.Gb;  
        }
    }
}

Powershell

#Create the audit 
$dbServer = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$dbAudit = New-Object Microsoft.SqlServer.Management.Smo.Audit($dbServer, "Test Audit")
$dbAudit.DestinationType = [Microsoft.SqlServer.Management.Smo.AuditDestinationType]'File'
$dbAudit.FilePath = "C:\AuditDirectory"
$dbAudit.Create()

#Set the audit file size units
$dbAudit.MaximumFileSizeUnit = [Microsoft.SqlServer.Management.Smo.AuditFileSizeUnit]'Gb'
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft