| external help file | PSDiagnostics-help.xml |
|---|---|
| Locale | en-US |
| Module Name | PSDiagnostics |
| ms.date | 10/01/2025 |
| online version | https://learn.microsoft.com/powershell/module/psdiagnostics/enable-pstrace?view=powershell-7.6&WT.mc_id=ps-gethelp |
| schema | 2.0.0 |
| title | Enable-PSTrace |
Enables the PowerShellCore event provider logs.
Enable-PSTrace [-Force] [-AnalyticOnly] [<CommonParameters>]
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.
The following example enables only the Analytic event log of the PowerShellCore provider.
Enable-PSTrace -AnalyticOnlyWhen this parameter is used, the cmdlet enables the Analytic event log of the PowerShellCore provider. The Operational event log is not changed.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseUsed to force the change without prompting.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
You can't pipe objects to this cmdlet.
This cmdlet returns no output.
This cmdlet uses the Get-LogProperties and Set-LogProperties cmdlets.
You must run this cmdlet from an elevated PowerShell session.