Last active
September 18, 2018 18:50
-
-
Save zippy1981/173f42c4f2e404785d7fbdb7a26ce014 to your computer and use it in GitHub Desktop.
Retrieve DCOM Errors from the Event Log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-ComNameByAppId { | |
param ( | |
[Guid] $AppId | |
) | |
(get-wmiobject -class "Win32_DCOMApplication" -namespace "root\CIMV2" -Filter "AppID = '{$AppId}'").Name | |
} | |
Get-EventLog -EntryType Error -LogName System |Where EventID -eq 10016 | % { | |
$ReplamentStringLength = $_.ReplacementStrings.Length; | |
$ClassId = $null; | |
$AppId = $null | |
$Name = $null | |
if ($ReplamentStringLength -ge 5) { | |
$ClassId = [Guid]$_.ReplacementStrings[3] | |
$AppId = [Guid] $_.ReplacementStrings[4] | |
$Name = Get-ComNameByAppId $AppId | |
} | |
else { | |
Write-Warning 'EventId $_.EventId does not appear to be a normal COM error' | |
} | |
New-Object 'PSObject' -Property @{ | |
EventId = $_.EventId; | |
Message = $_.Message; | |
ClassId = $ClassId; | |
AppId = $AppId; | |
Name = $Name | |
}; | |
} | Export-Csv -Path $env:USERPROFILE\Desktop\BrokenComObjects.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment