다음을 통해 공유


Audits 속성

Audit 개체의 컬렉션을 나타냅니다. 각 Audit 개체는 SQL Server 인스턴스에 정의된 감사 로그를 나타냅니다.

네임스페이스:  Microsoft.SqlServer.Management.Smo
어셈블리:  Microsoft.SqlServer.Smo(Microsoft.SqlServer.Smo.dll)

구문

‘선언
<SfcObjectAttribute(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny,  _
    GetType(Audit))> _
Public ReadOnly Property Audits As AuditCollection
    Get
‘사용 방법
Dim instance As Server
Dim value As AuditCollection

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

속성 값

유형: Microsoft.SqlServer.Management.Smo. . :: . .AuditCollection
SQL Server 인스턴스에 정의된 모든 감사 로그를 나타내는 AuditCollection 개체입니다.

C#

//Connect to the local server and create audits
Server srv = new Server("(local)");
testAudit1 = new Audit(srv, "First Test Audit");
testAudit1.DestinationType = AuditDestinationType.File;
testAudit1.FilePath = "C:\AuditDirectory";
testAudit1.Create();
testAudit2 = new Audit(srv, "Second Test Audit");
testAudit2.DestinationType = AuditDestinatinoType.File;
testAudit2.FilePath = "C:\AuditDirectory";
testAudit2.Create()

//Display the populated audit property
foreach (Audit a in srv.Audits)
{
   Console.WriteLine(a.Name);
}

PowerShell

#Connect to the local server and create audits
$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$testAudit1 = new-object Microsoft.SqlServer.Management.Smo.Audit($srv, "First Test Audit")
$testAudit1.DestinationType = [Microsoft.SqlServer.Management.Smo.AuditDestinationType]::File
$testAudit1.FilePath = "C:\AuditDirectory"
$testAudit2 = new-object Microsoft.SqlServer.Management.Smo.Audit($srv, "Second Test Audit")
$testAudit2.FilePath = "C:\AuditDirectory"
$testAudit2.DestinationType = [Microsoft.SqlServer.Management.Smo.AuditDestinationType]::File
$testAudit1.Create()
$testAudit2.Create()

#Display the populated audit property
foreach ($a in $srv.Audits)
{
   Write-Host $a.Name
}