다음을 통해 공유


Read-SqlXEvent

XEL 파일 또는 라이브 SQL XEvent 세션에서 SQL Server XEvents를 읽습니다.

구문

Read-SqlXEvent
    [-FileName] <String>
    [-ProgressAction <ActionPreference>]
    [<CommonParameters>]
Read-SqlXEvent
    -ConnectionString <String>
    -SessionName <String>
    [-ProgressAction <ActionPreference>]
    [<CommonParameters>]

Description

Read-SqlXEvent 파일 또는 라이브 SQL XEvent 세션에서 SQL Server XEvents를 읽습니다. 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 파일을 읽고 구문 분석합니다. 반환된 각 개체에는 단일 감사 레코드의 모든 정보가 포함됩니다.

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에서 XEvents의 라이브 스트림을 읽고 구문 분석합니다. 반환된 각 개체에는 단일 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
Position:Named
Default value:None
필수:True
파이프라인 입력 허용:False
와일드카드 문자 허용:False

-FileName

읽을 XEvent 파일의 파일 이름입니다.

형식:String
Position:0
Default value:None
필수:True
파이프라인 입력 허용:True
와일드카드 문자 허용:False

-ProgressAction

powerShell이 스크립트, cmdlet 또는 공급자(예: Write-Progress cmdlet에서 생성된 진행률 표시줄)에 의해 생성된 진행률 업데이트에 응답하는 방법을 결정합니다. Write-Progress cmdlet은 명령의 상태를 표시하는 진행률 표시줄을 만듭니다.

형식:ActionPreference
별칭:proga
Position:Named
Default value:None
필수:False
파이프라인 입력 허용:False
와일드카드 문자 허용:False

-SessionName

CREATE EVENT SESSION Transact-SQL에 정의된 SQL Server XEvent 세션 이름입니다.

형식:String
Position:Named
Default value:None
필수:True
파이프라인 입력 허용:False
와일드카드 문자 허용:False

입력

System.String

출력

Microsoft.SqlServer.XEvent.XELite.IXEvent