diff --git a/eng/scripts/dump_process.ps1 b/eng/scripts/dump_process.ps1 index 3c35ea29ee..f3ad56fcf7 100644 --- a/eng/scripts/dump_process.ps1 +++ b/eng/scripts/dump_process.ps1 @@ -1,9 +1,17 @@ Set-Location $args[0] -$timestamp = $(get-date -f MM-dd-HH-mm) - while ($true) { - Get-Process > artifacts/log/runningProcesses.$timestamp.txt - Get-WmiObject Win32_Process | select name, processid, commandline > artifacts/log/runningProcessesCommandLine.$timestamp.txt - Start-Sleep -Seconds 300 -} \ No newline at end of file + $local:file = "artifacts/log/runningProcesses.txt" + if (Test-Path $file) {Move-Item -Force $file "$file.bak"} + + $local:temp = Get-Process |Out-String -Width 300 + $temp.Split([Environment]::NewLine).TrimEnd() |? Length -gt 0 |Out-File -Width 300 $file + + $file = "artifacts/log/runningProcessesCommandLine.txt" + if (Test-Path $file) {Move-Item -Force $file "$file.bak"} + + $temp = Get-CimInstance Win32_Process |Format-Table -AutoSize Name, ProcessId, CommandLine |Out-String -Width 800 + $temp.Split([Environment]::NewLine).TrimEnd() |? Length -gt 0 |Out-File -Width 800 $file + + Start-Sleep -Seconds 120 +}