DateLastModified プロパティ
監査ログが最後に変更された日時を取得します。
名前空間: Microsoft.SqlServer.Management.Smo
アセンブリ: Microsoft.SqlServer.Smo (Microsoft.SqlServer.Smo.dll)
構文
'宣言
<SfcPropertyAttribute(SfcPropertyFlags.Standalone)> _
Public ReadOnly Property DateLastModified As DateTime
Get
'使用
Dim instance As Audit
Dim value As DateTime
value = instance.DateLastModified
[SfcPropertyAttribute(SfcPropertyFlags.Standalone)]
public DateTime DateLastModified { get; }
[SfcPropertyAttribute(SfcPropertyFlags::Standalone)]
public:
property DateTime DateLastModified {
DateTime get ();
}
[<SfcPropertyAttribute(SfcPropertyFlags.Standalone)>]
member DateLastModified : DateTime
function get DateLastModified () : DateTime
プロパティ値
型: System. . :: . .DateTime
監査ログが最後に更新された日時を示す DateTime システム オブジェクトの値。
使用例
次のコード例では、監査ログを最後に変更した日時を取得して、コンソールに表示する方法を示します。
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();
//Display the date of the most recent modification to the
//log on the console
DateTime auditModificationDate = dbAudit.DateLastModified;
Console.WriteLine("The most recent modification of the
audit log was made on " +
auditModificationDate.ToString());
}
}
}
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()
#Display the date of the most recent modification to the log
Write-Host "The most recent modification of the audit log was made on"
$dbAudit.DateLastModified