Compartir a través de


Audit.EnumServerAuditSpecification Método

Returns the name of the referenced server audit specification.

Espacio de nombres:  Microsoft.SqlServer.Management.Smo
Ensamblado:  Microsoft.SqlServer.Smo (en Microsoft.SqlServer.Smo.dll)

Sintaxis

'Declaración
Public Function EnumServerAuditSpecification As String
'Uso
Dim instance As Audit 
Dim returnValue As String 

returnValue = instance.EnumServerAuditSpecification()
public string EnumServerAuditSpecification()
public:
String^ EnumServerAuditSpecification()
member EnumServerAuditSpecification : unit -> string
public function EnumServerAuditSpecification() : String

Valor devuelto

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

Ejemplos

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

C#

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";
            dbAudit.Create();

            //Displays the name of the server audit specification
            Console.WriteLine(dbAudit.EnumServerAuditSpecification());
        }
    }
}

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()

#Write the name of the server audit specification, if one is defined
Write-Host $dbAudit.EnumServerAuditSpecification()

Vea también

Referencia

Audit Clase

Espacio de nombres Microsoft.SqlServer.Management.Smo