Edit

Share via


Enable-PSTrace

Enables the PowerShellCore event provider logs.

Syntax

Default (Default)

Enable-PSTrace
    [-Force]
    [-AnalyticOnly]
    [<CommonParameters>]

Description

This cmdlet is only available on the Windows platform.

This cmdlet enables the Operational and Analytic event logs of the PowerShellCore event provider.

You must run this cmdlet from an elevated PowerShell session.

Note

Prior to PowerShell 7.6, this command only enabled logging for the Microsoft-Windows-PowerShell event provider.

Examples

Example 1: Enable the Analytic event log for PowerShell

The following example enables only the Analytic event log of the PowerShellCore provider.

Enable-PSTrace -AnalyticOnly

Parameters

-AnalyticOnly

When this parameter is used, the cmdlet enables the Analytic event log of the PowerShellCore provider. The Operational event log is not changed.

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

-Force

Used to force the change without prompting.

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

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.

Notes

This cmdlet uses the Get-LogProperties and Set-LogProperties cmdlets.

You must run this cmdlet from an elevated PowerShell session.