Created
April 21, 2017 11:18
-
-
Save bill-long/6ae774d47237d36cf8949211f8d3ffc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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