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
classes. We do this as follows:Add-Type -AssemblyName "Microsoft.SqlServer.ConnectionInfo, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Add-Type -AssemblyName "Microsoft.SqlServer.ConnectionInfoExtended...