< Back

New-DbaXESmartCsvWriter

Mon Jan 13, 2020 1:01 pm

NAME New-DbaXESmartCsvWriter



SYNOPSIS

This response type is used to write Extended Events to a CSV file.





SYNTAX

New-DbaXESmartCsvWriter [-OutputFile] <String> [-Overwrite <Switch>] [[-Event] <System.String[]>] [[-OutputColumn]

<System.String[]>] [[-Filter] <String>] [-EnableException <Switch>] [<CommonParameters>]





DESCRIPTION

This response type is used to write Extended Events to a CSV file.





PARAMETERS

-EnableException [<Switch>]

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.

This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables

advanced scripting.

Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own

try/catch.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Event [<System.String[]>]

Specifies a list of events to be processed (with others being ignored. By default, all events are processed.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Filter [<String>]

Specifies a filter expression in the same form as you would use in the WHERE clause of a SQL query.



Example: duration > 10000 AND cpu_time > 10000



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-OutputColumn [<System.String[]>]

Specifies the list of columns to output from the events. XESmartTarget will capture in memory and write to the

target table only the columns (fields or targets) that are present in this list.



Fields and actions are matched in a case-sensitive manner.



Expression columns are supported. Specify a column with ColumnName AS Expression to add an expression column

(Example: Total AS Reads + Writes)



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-OutputFile [<String>]

Specifies the path to the output CSV file.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Overwrite [<Switch>]

Specifies whether any existiting file should be overwritten or not.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: ExtendedEvent, XE, XEvent, SmartTarget

Author: Chrissy LeMaire (@cl) | SmartTarget by Gianluca Sartori (@spaghettidba)



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>$columns = "cpu_time", "duration", "physical_reads", "logical_reads", "writes", "row_count"



PS C:\\> $response = New-DbaXESmartCsvWriter -OutputFile c:\\temp\\workload.csv -OutputColumn $columns -OverWrite

-Event "sql_batch_completed"

PS C:\\> Start-DbaXESmartTarget -SqlInstance localhost\\sql2017 -Session "Profiler Standard" -Responder $response



Writes Extended Events to the file "C:\\temp\\workload.csv".



RELATED LINKS

https://dbatools.io/New-DbaXESmartCsvWriter