Skip to content

Instantly share code, notes, and snippets.

@zippy1981
Last active September 18, 2018 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zippy1981/173f42c4f2e404785d7fbdb7a26ce014 to your computer and use it in GitHub Desktop.
Save zippy1981/173f42c4f2e404785d7fbdb7a26ce014 to your computer and use it in GitHub Desktop.
Retrieve DCOM Errors from the Event Log
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