dump_process.ps1 670 B

1234567891011121314151617
  1. Set-Location $args[0]
  2. while ($true) {
  3. $local:file = "artifacts/log/runningProcesses.txt"
  4. if (Test-Path $file) {Move-Item -Force $file "$file.bak"}
  5. $local:temp = Get-Process |Out-String -Width 300
  6. $temp.Split([Environment]::NewLine).TrimEnd() |? Length -gt 0 |Out-File -Width 300 $file
  7. $file = "artifacts/log/runningProcessesCommandLine.txt"
  8. if (Test-Path $file) {Move-Item -Force $file "$file.bak"}
  9. $temp = Get-CimInstance Win32_Process |Format-Table -AutoSize Name, ProcessId, CommandLine |Out-String -Width 800
  10. $temp.Split([Environment]::NewLine).TrimEnd() |? Length -gt 0 |Out-File -Width 800 $file
  11. Start-Sleep -Seconds 120
  12. }