Extracting the contents of a trace file
In this recipe, we will extract the contents of a trace (.trc
) file using PowerShell.
Getting ready
We will need to use the x86 Version of PowerShell and/or PowerShell ISE for this recipe. This is unfortunate, but some of the classes that we need to use are only supported in 32-bit mode.
In this recipe, we will use a previously saved trace (.trc
) file. Feel free to substitute this with a trace file that is available.
How to do it...
Let's take a look at how we can extract the contents of a trace file:
- Open PowerShell ISE as an administrator.
- Import the
SQLPS
module:#import SQL Server module Import-Module SQLPS -DisableNameChecking
- Import additional libraries. These are needed to use our
TraceFile
andTraceServer ...
Get SQL Server 2014 with PowerShell v5 Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.