Udostępnij za pośrednictwem


Właściwość Audit.Guid

Pobiera lub ustawia identyfikator unikatowy system inspekcji odwołanie.

Przestrzeń nazw:  Microsoft.SqlServer.Management.Smo
Zestaw:  Microsoft.SqlServer.Smo (w Microsoft.SqlServer.Smo.dll)

Składnia

'Deklaracja
<SfcPropertyAttribute(SfcPropertyFlags.None Or SfcPropertyFlags.ReadOnlyAfterCreation Or SfcPropertyFlags.Standalone)> _
Public Property Guid As Guid
    Get
    Set
'Użycie
Dim instance As Audit
Dim value As Guid

value = instance.Guid

instance.Guid = value
[SfcPropertyAttribute(SfcPropertyFlags.None|SfcPropertyFlags.ReadOnlyAfterCreation|SfcPropertyFlags.Standalone)]
public Guid Guid { get; set; }
[SfcPropertyAttribute(SfcPropertyFlags::None|SfcPropertyFlags::ReadOnlyAfterCreation|SfcPropertyFlags::Standalone)]
public:
property Guid Guid {
    Guid get ();
    void set (Guid value);
}
[<SfcPropertyAttribute(SfcPropertyFlags.None|SfcPropertyFlags.ReadOnlyAfterCreation|SfcPropertyFlags.Standalone)>]
member Guid : Guid with get, set
function get Guid () : Guid
function set Guid (value : Guid)

Wartość właściwości

Typ: System.Guid
A Guid wartość, która określa identyfikator unikatowy system inspekcji odwołanie.

Przykłady

Poniższy przykład kodu pokazuje sposób wygenerowania inspekcji unikatowy identyfikator GUID i wyświetlić go na konsoli.

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();
            
            //Get the GUID and display it on the console
            Console.WriteLine("The GUID of the audit log file is: " +
                              dbAudit.Guid);
        }
    }
}

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

#Get and display the GUID
Write-Host "The GUID of the audit log file is:" $dbAudit.Guid