Running and saving a profiler trace event

In this recipe, we will run and save a profiler trace event using PowerShell.

Getting ready

To run and save a profiler trace event, we will need to use the x86 Version of PowerShell and/or PowerShell ISE. 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 need to use the standard trace template definition file (TDF) as our starting template for the trace we're going to run. This can be found in C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Profiler\Templates\Microsoft SQL Server\110\Standard.tdf.

For our purposes, we are also going to limit the number of events to 10.

How to do it...

Let's take a look at the steps to run and save ...

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.