Start-Trace

Start an Event Trace logging session.

Syntax

Start-Trace
     [-SessionName] <String>
     [[-OutputFilePath] <String>]
     [[-ProviderFilePath] <String>]
     [-ETS]
     [-Format <String>]
     [-MinBuffers <Int32>]
     [-MaxBuffers <Int32>]
     [-BufferSizeInKB <Int32>]
     [-MaxLogFileSizeInMB <Int32>]
     [<CommonParameters>]

Description

This cmdlet is only available on the Windows platform.

This cmdlet starts a Windows Event Trace logging session.

This cmdlet is used by the following cmdlets:

  • Enable-PSWSManCombinedTrace
  • Enable-WSManTrace

You must run this cmdlet from an elevated PowerShell session.

Examples

Example 1: Start a WSMan Trace logging session

$parameters = @{
    SessionName         = 'wsmlog'
    ETS                 = $true
    OutputFilePath      = "$env:windir\system32\wsmtraces.log"
    Format              = 'bincirc'
    MinBuffers          = 16
    MaxBuffers          = 256
    BufferSizeInKb      = 64
    MaxLogFileSizeInMB  = 256
    ProviderFilePath    = "$env:windir\system32\wsmtraceproviders.txt"
}
Start-Trace @parameters

Parameters

-BufferSizeInKB

Event Trace Session buffer size in kilobytes (KB).

Type:Int32
Position:Named
Default value:0
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ETS

Send commands to Event Trace Sessions directly without saving or scheduling.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Format

Specifies the log format for the data collector. For SQL database format, you must use the OutputFilePath option in the command line with the dsn!log value. The default is binary (bin). The possible values are:

  • bin - binary
  • bincirc - binary with circular logging
  • csv - Comma-separated values
  • tsv - Tab-separated values
  • sql - SQL database
Type:Object
Accepted values:bin, bincirc, csv, tsv, sql
Position:Named
Default value:bin
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-MaxBuffers

Sets the maximum number of Event Trace Session buffers.

Type:Int32
Position:Named
Default value:256
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-MaxLogFileSizeInMB

Sets the maximum log file size in megabytes (MB) or number of records for SQL logs.

Type:Int32
Position:Named
Default value:0 (no limit)
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-MinBuffers

Sets the minimum number of Event Trace Session buffers.

Type:Int32
Position:Named
Default value:0
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-OutputFilePath

Path of the output log file or the DSN and log set name in a SQL database. The default path is $env:systemdrive\PerfLogs\Admin.

Type:String
Position:1
Default value:$env:systemdrive\PerfLogs\Admin
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ProviderFilePath

File listing multiple Event Trace providers to enable.

Type:String
Position:2
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SessionName

The name of the Event Trace session. To stop a trace session you must know the session name.

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

Inputs

None

You can't pipe objects to this cmdlet.

Outputs

None

This cmdlet returns no output.