Skip to content

Instantly share code, notes, and snippets.

@batzen
Last active March 7, 2022 09:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save batzen/84790c26757c3420c5ee to your computer and use it in GitHub Desktop.
Save batzen/84790c26757c3420c5ee to your computer and use it in GitHub Desktop.
Short PowerShell script to start sxstrace, stop sxstrace and open the resulting trace
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
Write-Warning "You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!"
break
}
$logfile = (Join-Path $env:temp sxstrace.log)
$outfile = (Join-Path $env:temp sxstrace.txt)
Write-Output "Starting sxstrace utility..."
sxstrace trace -logfile:$logfile -nostop
Write-Output "Press any key to stop tracing"
Read-Host
sxstrace stoptrace
&sxstrace parse -logfile:$logfile -outfile:$outfile
Invoke-Item $outfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment