Audit.Disable メソッド

監査を無効にします。

名前空間:  Microsoft.SqlServer.Management.Smo
アセンブリ:  Microsoft.SqlServer.Smo (Microsoft.SqlServer.Smo.dll)

構文

'宣言
Public Sub Disable
'使用
Dim instance As Audit

instance.Disable()
public void Disable()
public:
void Disable()
member Disable : unit -> unit
public function Disable()

説明

Disable メソッドは、監査が既に有効な場合、これを無効にします。 Enable メソッドを使用して以前に監査を有効にしていない場合、Disable が呼び出されても、処理は何も実行されません。

使用例

次のコード例では、監査を無効にする方法を示します。

C#

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

           //Enable the audit
            dbAudit.Enable();
            Console.WriteLine("The audit is enabled")

            //Disable the audit
            dbAudit.Disable();
            if (dbAudit.Enabled == false)
            { 
            Console.WriteLine("The audit has been disabled");
            }
        }
    }
}

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

#Enable the audit
$dbAudit.Enable()
Write-Host "The audit is enabled"

#Disable the audit
$dbAudit.Disable()
If ($dbAudit.Enabled -eq $FALSE)
{
   Write-Host "The audit has been disabled"
}

関連項目

参照

Audit クラス

Microsoft.SqlServer.Management.Smo 名前空間