Export (0) Print
Expand All

Audit.EnumServerAuditSpecification Method ()


Applies To: SQL Server 2016 Preview

Returns the name of the referenced server audit specification.

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

public string EnumServerAuditSpecification()

Return Value

Type: System.String

A String object that contains the name of the server audit specification.

Legacy Code Example

The following code example demonstrates how to return the name of the audit specification and display it on the console.


using System;
using System.Data;
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";

            //Displays the name of the server audit specification


#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"

#Write the name of the server audit specification, if one is defined
Write-Host $dbAudit.EnumServerAuditSpecification()
Return to top
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft