extract_failed_ids.ps1 1.1 KB

123456789101112131415161718192021
  1. if (Test-Path -Path $args[0] -PathType Leaf) {
  2. $file=$args[0]
  3. }
  4. else {
  5. Write-Host "CANNOT FIND LOG FILE"
  6. Exit 1
  7. }
  8. if ($args[1] -ne $null) {
  9. $output=$args[1]
  10. Write-Host "Outputting IDs to $output"
  11. }
  12. else {
  13. $output="./failed.txt"
  14. }
  15. Select-String -Path $file -Pattern "Could not download submission" | ForEach-Object { -split $_.Line | Select-Object -Skip 11 | Select-Object -First 1 } | foreach { $_.substring(0,$_.Length-1) } >> $output
  16. Select-String -Path $file -Pattern "Failed to download resource" | ForEach-Object { -split $_.Line | Select-Object -Skip 14 | Select-Object -First 1 } >> $output
  17. Select-String -Path $file -Pattern "failed to download submission" | ForEach-Object { -split $_.Line | Select-Object -Skip 13 | Select-Object -First 1 } | foreach { $_.substring(0,$_.Length-1) } >> $output
  18. Select-String -Path $file -Pattern "Failed to write file" | ForEach-Object { -split $_.Line | Select-Object -Skip 13 | Select-Object -First 1 } >> $output
  19. Select-String -Path $file -Pattern "skipped due to disabled module" | ForEach-Object { -split $_.Line | Select-Object -Skip 8 | Select-Object -First 1 } >> $output