次の方法で共有


Read-SqlXEvent

XEL ファイルまたはライブ SQL XEvent セッションから SQL Server XEvent を読み取ります。

構文

ByFile (既定)

Read-SqlXEvent
    [-FileName] <String>
    [<CommonParameters>]

ByLiveData

Read-SqlXEvent
    -ConnectionString <String>
    -SessionName <String>
    [<CommonParameters>]

説明

Read-SqlXEvent は、ファイルまたはライブ SQL XEvent セッションから SQL Server XEvent を読み取ります。 XEvent セッションは、CREATE EVENT SESSION Transact-SQL API によって作成されます。 SQL XEvent ファイルには通常、XEL または .sqlaudit 拡張機能。XEvents のストリームが含まれています。 XEvents の構造は、セッション構成で定義されます。 SQL ライブ ストリームは SQL TDS プロトコルを介して使用でき、生成されたサーバーに対する認証が必要です。

New in v22: if you are using the -ConnectionString parameter, you may get an error like "The certificate chain was issued by an authority that is not trusted." This is because the new SQL driver changed its default to something more secure. Either make sure you configure your server properly, or install/trust the certificate; alternatively (not recommended), you can pass Encrypt=Optional or TrustServerCertificate=true in the connection string to go back to the behavior that existed in v21 of the module.

例 1: sqlaudit ファイルを読み取って解析する。 返される各オブジェクトには、1 つの監査レコードのすべての情報が含まれます。

Read-SqlXEvent -FileName C:\audits\Audit-20190529-132659.sqlaudit

# The output would look like this:
#
# Name      : audit_event
# UUID      : c6479a6f-f1bd-4759-9881-fcb493821aff
# Timestamp : 6/13/2019 7:49:42 AM +00:00
# Fields    : {[audit_schema_version, 1], [event_time, 6/13/2019 7:49:42 AM +00:00], [sequence_number, 1], [action_id,
#             1129534785]...}
# Actions   : {}
#
# Name      : audit_event
# UUID      : c6479a6f-f1bd-4759-9881-fcb493821aff
# Timestamp : 6/13/2019 12:42:28 PM +00:00
# Fields    : {[audit_schema_version, 1], [event_time, 6/13/2019 12:42:28 PM +00:00], [sequence_number, 1], [action_id,
#             1129534785]...}
# Actions   : {}
# ...

例 2: Windows 認証に接続されている同じコンピューターで実行されている SQL Server から XEvent のライブ ストリームを読み取って解析する。 返される各オブジェクトには、1 つの XEvent レコードのすべての情報が含まれます。

Read-SQLXEvent -ConnectionString "Server=.;Database=master;Trusted_Connection=True" -SessionName telemetry_xevents

# The output would look like this:
#
# Name      : auto_stats
# UUID      : 9237e17a-a73d-4832-8936-f319e19e219b
# Timestamp : 11/14/2022 5:31:12 AM +00:00
# Fields    : {[database_id, 1], [object_id, 74], [index_id, 1], [job_id, 0]…}
# Actions   : {}
#
# Name      : auto_stats
# UUID      : 9237e17a-a73d-4832-8936-f319e19e219b
# Timestamp : 11/14/2022 5:31:12 AM +00:00
# Fields    : {[database_id, 1], [object_id, 74], [index_id, 17], [job_id, 0]…}
# Actions   : {}
# ...

パラメーター

-ConnectionString

SQL Server 接続文字列。

パラメーターのプロパティ

型:String
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

ByLiveData
配置:Named
必須:True
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-FileName

読み取る XEvent ファイルのファイル名。

パラメーターのプロパティ

型:String
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

ByFile
配置:0
必須:True
パイプラインからの値:True
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-SessionName

CREATE EVENT SESSION Transact-SQL で定義されている SQL Server XEvent セッション名。

パラメーターのプロパティ

型:String
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

ByLiveData
配置:Named
必須:True
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

CommonParameters

このコマンドレットでは、一般的なパラメーター -Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction、-WarningVariable の各パラメーターがサポートされています。 詳細については、about_CommonParametersを参照してください。

入力

System.String

出力

Microsoft.SqlServer.XEvent.XELite.IXEvent