Read-SqlXEvent
Legge GLI XEvent di SQL Server dal file XEL o dalla sessione XEvent di SQL live.
Sintassi
ByFile (impostazione predefinita).
Read-SqlXEvent
[-FileName] <String>
[<CommonParameters>]
ByLiveData
Read-SqlXEvent
-ConnectionString <String>
-SessionName <String>
[<CommonParameters>]
Descrizione
Il Read-SqlXEvent legge gli eventi XEvent di SQL Server da un file o da una sessione XEvent di SQL live. Le sessioni XEvent vengono create dall'API CREATE EVENT SESSION Transact-SQL. I file XEvent di SQL hanno in genere . Estensioni XEL o .sqlaudit e contengono un flusso di eventi XEvent. La struttura degli eventi XEvent è definita nella configurazione della sessione. I flussi live SQL sono disponibili tramite il protocollo TDS SQL e richiedono l'autenticazione sul server che li ha generati.
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.
Esempio
Esempio 1: leggere e analizzare il file sqlaudit. Ogni oggetto restituito conterrà tutte le informazioni di un singolo record di controllo.
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 : {}
# ...
Esempio 2: Leggere e analizzare il flusso live di XEvents da SQL Server in esecuzione nello stesso computer connesso con l'autenticazione di Windows. Ogni oggetto restituito conterrà tutte le informazioni di un singolo record 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 : {}
# ...
Parametri
-ConnectionString
Stringa di connessione di SQL Server.
Proprietà dei parametri
| Tipo: | String |
| Valore predefinito: | None |
| Supporta i caratteri jolly: | False |
| DontShow: | False |
Set di parametri
ByLiveData
| Posizione: | Named |
| Obbligatorio: | True |
| Valore dalla pipeline: | False |
| Valore dalla pipeline in base al nome della proprietà: | False |
| Valore dagli argomenti rimanenti: | False |
-FileName
Nome file di un file XEvent da leggere.
Proprietà dei parametri
| Tipo: | String |
| Valore predefinito: | None |
| Supporta i caratteri jolly: | False |
| DontShow: | False |
Set di parametri
ByFile
| Posizione: | 0 |
| Obbligatorio: | True |
| Valore dalla pipeline: | True |
| Valore dalla pipeline in base al nome della proprietà: | False |
| Valore dagli argomenti rimanenti: | False |
-SessionName
Nome della sessione XEvent di SQL Server come definito dal transact-SQL CREATE EVENT SESSION.
Proprietà dei parametri
| Tipo: | String |
| Valore predefinito: | None |
| Supporta i caratteri jolly: | False |
| DontShow: | False |
Set di parametri
ByLiveData
| Posizione: | Named |
| Obbligatorio: | True |
| Valore dalla pipeline: | False |
| Valore dalla pipeline in base al nome della proprietà: | False |
| Valore dagli argomenti rimanenti: | False |
CommonParameters
Questo cmdlet supporta i parametri comuni: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction e -WarningVariable. Per altre informazioni, vedi about_CommonParameters.