Skip to content

Instantly share code, notes, and snippets.

@bill-long
Created April 21, 2017 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bill-long/6ae774d47237d36cf8949211f8d3ffc0 to your computer and use it in GitHub Desktop.
Save bill-long/6ae774d47237d36cf8949211f8d3ffc0 to your computer and use it in GitHub Desktop.
$wprBinary = 'C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\wpr.exe'
$wprDataFolder = 'D:\wprdata'
$numberOfFilesToKeep = 5
$localComputerName = [Environment]::MachineName
while ($true)
{
"Starting..."
& $wprBinary -start CPU
"WPR started at " + (Get-Date).ToString()
Start-Sleep 120
" Stopping at " + (Get-Date).ToString()
& $wprBinary -stop (Join-Path $wprDataFolder ($localComputerName + "-" + [DateTime]::Now.ToString("yyyyMMddHHmmss") + "-WPR.etl"))
$files = Get-ChildItem $dataFolder *.etl
$oldest = $files | Sort-Object CreationTime | Select-Object -First 1
if ($files.Length -gt $numberOfFilesToKeep)
{
Remove-Item $oldest
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment