Edit

Share via


Start-Trace

Start an Event Trace logging session.

Syntax

Default (Default)

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).

Parameter properties

Type:Int32
Default value:0
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ETS

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

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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

Parameter properties

Type:Object
Default value:bin
Accepted values:bin, bincirc, csv, tsv, sql
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-MaxBuffers

Sets the maximum number of Event Trace Session buffers.

Parameter properties

Type:Int32
Default value:256
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-MaxLogFileSizeInMB

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

Parameter properties

Type:Int32
Default value:0 (no limit)
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-MinBuffers

Sets the minimum number of Event Trace Session buffers.

Parameter properties

Type:Int32
Default value:0
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:String
Default value:$Env:SystemDrive\PerfLogs\Admin
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:1
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ProviderFilePath

File listing multiple Event Trace providers to enable.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:2
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SessionName

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

None

You can't pipe objects to this cmdlet.

Outputs

None

This cmdlet returns no output.