Server.ServerAuditSpecifications Server.ServerAuditSpecifications Server.ServerAuditSpecifications Property

Definition

Represents a collection of ServerAuditSpecification objects. Each ServerAuditSpecification object represents a specific audit specification defined on the instance of SQL Server.

public:
 property Microsoft::SqlServer::Management::Smo::ServerAuditSpecificationCollection ^ ServerAuditSpecifications { Microsoft::SqlServer::Management::Smo::ServerAuditSpecificationCollection ^ get(); };
[Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcObject(Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcContainerRelationship.ObjectContainer, Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcContainerCardinality.ZeroToAny, typeof(Microsoft.SqlServer.Management.Smo.ServerAuditSpecification))]
public Microsoft.SqlServer.Management.Smo.ServerAuditSpecificationCollection ServerAuditSpecifications { get; }
Public ReadOnly Property ServerAuditSpecifications As ServerAuditSpecificationCollection
Property Value

A ServerAuditSpecificationCollection object that represents all the audit specifications defined on the instance of SQL Server.

Examples

C#

Server srv = new Server("(local)");  

ServerAuditSpecification aSpec = new ServerAuditSpecification(srv, "Example Audit Specification");  
Audit srvAudit = new Audit(srv, "Test Audit");  
srvAudit.DestinationType = AuditDestinationType.File;  
srvAudit.FilePath = "C:\\AuditDirectory";  
srvAudit.Create();  

aSpec.AuditName = "Test Audit";  
aSpec.Create();  

foreach (ServerAuditSpecification a in srv.ServerAuditSpecifications)  
{  
   Console.WriteLine(a.Name);  
}  

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$srvAudit = new-object Microsoft.SqlServer.Management.Smo.Audit($srv, "Test Audit")  
$srvAudit.DestinationType = [Microsoft.SqlServer.Management.Smo.AuditDestinationType]::File  
$srvAudit.FilePath = "C:\AuditDirectory"  
$srvAudit.Create()  

Foreach ($a in $srv.ServerAuditSpecifications)  
{  
   Write-Host $a.Name  
}  

Applies to