Private/Get-MessageInformation.ps1
function Get-MessageInformation { [CmdletBinding()] param ( $MessageID ) $msg = $MessagesXML.dtsHealthCheck.Message | Where-Object {$_.MessageId -eq $MessageID} if ($null -eq $msg) { Write-Verbose "searching windows update error table" $errcodes = Join-Path $(Split-Path (Get-Module "cmhealthcheck").Path) -ChildPath "assets\windows_update_errorcodes.txt" if (Test-Path $errcodes) { $errdata = Import-Csv -Path $errcodes $errdet = $($errdata | Where-Object {$_.ErrorCode -eq $MessageID} | Select-Object -ExpandProperty Description).Trim() if ([string]::IsNullOrEmpty($errdet)) { $errdet = $($errdata | Where-Object {$_.DecErrorCode -eq $MessageID} | Select-Object -ExpandProperty Description).Trim() if (![string]::IsNullOrEmpty($errdet)) { Write-Output $errdet } else { Write-Output "There is no known possible solution for Message ID $MessageID" } } else { Write-Output $errdet } } else { Write-Warning "missing file: $errcodes" Write-Output "Unknown Message ID $MessageID" } } else { Write-Output $msg.Description } } |