dbatools is a free PowerShell module with over 300 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Read-DbaTraceFile

Using the fn_trace_gettable function, a trace file is read and returned as a PowerShell object.

This function returns the whole of the trace file. The information is presented in the format that the trace subsystem uses.

Screenshots

dbatools - read-dbatracefile

Examples

Reads the tracefile C:\traces\big.trc, stored on the sql2016 sql server. Filters only results that have master or tempdb as the DatabaseName.

Read-DbaTraceFile -SqlInstance sql2016 -Database master, tempdb -Path C:\traces\big.trc

Reads the tracefile C:\traces\big.trc, stored on the sql2016 sql server.
Filters only results that have master or tempdb as the DatabaseName and that have ‘EXEC SP_PROCOPTION’ somewhere in the text.

Read-DbaTraceFile -SqlInstance sql2016 -Database master, tempdb -Path C:\traces\big.trc -TextData ‘EXEC SP_PROCOPTION’

Reads the tracefile C:\traces\big.trc, stored on the sql2016 sql server.
Filters only results where LinkServerName = myls and StartTime is greater than ‘5/30/2017 4:27:52 PM’.

Read-DbaTraceFile -SqlInstance sql2016 -Path C:\traces\big.trc -Where “LinkedServerName = ‘myls’ and StartTime > ‘5/30/2017 4:27:52 PM'”

Author

This command was created by Chrissy LeMaire. You can find Chrissy on Twitter.

Get-Help

From PowerShell, execute Get-Help Read-DbaTraceFile -Detailed for more information on this function.

Source Code

Want to see the source code? View Read-DbaTraceFile.ps1 on GitHub
 

Related commands