########################## # Writer: Claudio Boggian # Company: PAL s.r.l. #------------------------- # Date: 2024/02/20 # v: 1.0 # Reason: Emission #------------------------- ########################## $exitState = 0 $numero = 0 $numeroErrori = 0 $filePathApplication = "C:\Program Files\Microsoft Dynamics AX\60\Server\AX2012R2_PAL_DEV\bin\XppIL\Dynamics.Ax.Application.dll.log" $filePathAxCompileAll = "C:\Program Files\Microsoft Dynamics AX\60\Server\AX2012R2_PAL_DEV\Log\AxCompileAll.html" Get-Content $filePathApplication | ForEach-Object { if ($_ -match "Errors:\s+(\d+)") { $numero = $matches[1] } } if ($numero -notlike 0) { Write-Output "Errors Ax Application: $numero" $exitState = 2 } $content = Get-Content $filePathAxCompileAll foreach ($row in $content) { if ($row -match "Errors\s*:\s*(\d+)") { $numeroErrori = $matches[1] } } if ($numeroErrori -notlike 0) { Write-Output "Errors Ax Compile: $numeroErrori" $exitState = 2 $errorDetails = @() $recordStart = $false $currentRecord = @{} foreach ($row in $content) { if ($row -match '(.+?)') { $currentRecord["PercorsoErrore"] = $matches[1] } if ($row -match '(\d+)') { $currentRecord["Colonna"] = $matches[1] } if ($row -match '(\d+)') { $currentRecord["Linea"] = $matches[1] } if ($row -match '(\d+)') { $currentRecord["CodiceErrore"] = $matches[1] } if ($row -match '') { $currentRecord["MessaggioErrore"] = $matches[1] } if ($row -match '0') { $currentRecord["Severità"] = "Errore" } } if ($row -match "" -and $recordStart) { $recordStart = $false if ($currentRecord["Severità"] -eq "Errore") { $errorDetails += [PSCustomObject]@{ Severity = $currentRecord["Severità"] ErrorPath = $currentRecord["PercorsoErrore"] Line = $currentRecord["Linea"] Colomn = $currentRecord["Colonna"] ErrorMessage = $currentRecord["MessaggioErrore"] ErrorCode = $currentRecord["CodiceErrore"] } } } } Write-Output $errorDetails | Format-Table -Autosize } if ($exitState -eq 0) { Write-Output "OK! No errors found" } Exit $exitState