共用方式為


Server.ServerAuditSpecifications 屬性

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

命名空間:  Microsoft.SqlServer.Management.Smo
組件:  Microsoft.SqlServer.Smo (在 Microsoft.SqlServer.Smo.dll 中)

語法

'宣告
<SfcObjectAttribute(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny,  _
    GetType(ServerAuditSpecification))> _
Public ReadOnly Property ServerAuditSpecifications As ServerAuditSpecificationCollection 
    Get
'用途
Dim instance As Server 
Dim value As ServerAuditSpecificationCollection 

value = instance.ServerAuditSpecifications
[SfcObjectAttribute(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny, 
    typeof(ServerAuditSpecification))]
public ServerAuditSpecificationCollection ServerAuditSpecifications { get; }
[SfcObjectAttribute(SfcContainerRelationship::ObjectContainer, SfcContainerCardinality::ZeroToAny, 
    typeof(ServerAuditSpecification))]
public:
property ServerAuditSpecificationCollection^ ServerAuditSpecifications {
    ServerAuditSpecificationCollection^ get ();
}
[<SfcObjectAttribute(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny, 
    typeof(ServerAuditSpecification))>]
member ServerAuditSpecifications : ServerAuditSpecificationCollection
function get ServerAuditSpecifications () : ServerAuditSpecificationCollection

屬性值

型別:Microsoft.SqlServer.Management.Smo.ServerAuditSpecificationCollection
A ServerAuditSpecificationCollection object that represents all the audit specifications defined on the instance of SQL Server.

範例

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
}

請參閱

參考

Server 類別

Microsoft.SqlServer.Management.Smo 命名空間

其他資源

使用集合

管理伺服器