エラーログファイルには、設定されたエラー文字列と一致しないすべての行がコピーされます。だから、基本的に私は認識できないエラーのファイルを作り上げています。私はこれは私がファイルに文字列に基づいて行を削除してください
(Get-Content $path\temp_report.log) |
Where-Object { $_ -notmatch $error_1 } |
Out-File $path\uncategorised_errors.log
(Get-Content $path\temp_report.log) |
Where-Object { $_ -notmatch $error_2 } |
Out-File $path\uncategorised_errors.log
(Get-Content $path\temp_report.log) |
Where-Object { $_ -notmatch $error_3 } |
Out-File $path\uncategorised_errors.log
私の入力ファイルを読むためにやっているものです
# Define all the error types that we need to search on
$error_1 = "Start Date must be between 1995 and 9999"
$error_2 = "SYSTEM.CONTACT_TYPE"
$error_3 = "DuplicateExternalSystemIdException"
$error_4 = "From date after To date in address"
$error_5 = "Missing coded entry for provider type category record"
と、すべての既知のエラータイプを定義
は、このようなものです:
15 Jul 2016 20:02:11,340 ExternalSystemId cannot be the same as an existing provider 15 Jul 2016 20:02:11,340 XXXXXXXXXXXXXXXXXXXXXXXXX 15 Jul 2016 20:02:11,340 ZZZZZZZZZZZZZZZZZZZZZZZZ 15 Jul 2016 20:02:11,340 DuplicateExternalSystemIdException 15 Jul 2016 20:02:11,340 DuplicateExternalSystemIdException 15 Jul 2016 20:02:11,340 SYSTEM.CONTACT_TYPE
と私のアウトはちょうど私が3行しか持っていないと同じです:
15 Jul 2016 20:02:11,340 ExternalSystemId cannot be the same as an existing provider 15 Jul 2016 20:02:11,340 XXXXXXXXXXXXXXXXXXXXXXXXX 15 Jul 2016 20:02:11,340 ZZZZZZZZZZZZZZZZZZZZZZZZ
作品を使用しています。私はちょうどこの作品を手に入れましたが、あなたの答えはよりエレガントで、ちょうど1つのライナーです。 $結果= Get-Content $ path \ temp_report.log $ result | Where-Object {$ _ -notmatch [regex] ::エスケープ($ error_1)} |セット内容$ path \ uncategorised_errors.log – zoomzoomvince