Audit.OnFailure Audit.OnFailure Audit.OnFailure Property


Gets or sets the action taken when the audit fails.

 property Microsoft::SqlServer::Management::Smo::OnFailureAction OnFailure { Microsoft::SqlServer::Management::Smo::OnFailureAction get(); void set(Microsoft::SqlServer::Management::Smo::OnFailureAction value); };
public Microsoft.SqlServer.Management.Smo.OnFailureAction OnFailure { get; set; }
Public Property OnFailure As OnFailureAction
Property Value

A OnFailureAction value that specifies the type of action taken after the audit fails, such as whether to continue or shut down the system.


The following code example demonstrates how to configure the system to shut down after an audit fails.


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

            //Set the system to shut down if the audit fails  
            dbAudit.OnFailure = OnFailureAction.Shutdown;  


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

#Set the system to shut down if the audit fails  
$dbAudit.OnFailure = [Microsoft.SqlServer.Management.Smo.OnFailureAction]'Shutdown'  

Applies to