다음을 통해 공유


Read-SqlXEvent

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

구문

ByFile (기본값)

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

ByLiveData

Read-SqlXEvent
    -ConnectionString <String>
    -SessionName <String>
    [<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
Default value:None
와일드카드 지원:False
DontShow:False

매개 변수 집합

ByLiveData
Position:Named
필수:True
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-FileName

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

매개 변수 속성

형식:String
Default value:None
와일드카드 지원:False
DontShow:False

매개 변수 집합

ByFile
Position:0
필수:True
파이프라인의 값:True
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-SessionName

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

매개 변수 속성

형식:String
Default value:None
와일드카드 지원:False
DontShow:False

매개 변수 집합

ByLiveData
Position:Named
필수:True
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

CommonParameters

이 cmdlet은 일반적인 매개 변수인 -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction 및 -WarningVariable 매개 변수를 지원합니다. 자세한 내용은 about_CommonParameters를 참조하세요.

입력

System.String

출력

Microsoft.SqlServer.XEvent.XELite.IXEvent