Skip to content

Instantly share code, notes, and snippets.

Last active April 14, 2019 01:43
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
If you have the HgsDiagnostics PowerShell module, then you can parse TCG logs.
Import-Module HgsDiagnostics
$GetHgsTrace = Get-Command Get-HgsTrace
$RemoteAttestationCoreReference = $GetHgsTrace.ImplementingType.Assembly.GetReferencedAssemblies() | Where-Object { $_.Name -eq 'Microsoft.Windows.RemoteAttestation.Core' }
Add-Type -AssemblyName $RemoteAttestationCoreReference.FullName
$MostRecentTCGLog = Get-ChildItem C:\Windows\Logs\MeasuredBoot | Sort-Object -Property LastWriteTime -Descending | Select-Object -First 1 | Select-Object -ExpandProperty FullName
$LogBytes = [IO.File]::ReadAllBytes($MostRecentTCGLog)
$ParsedTCGLog = [Microsoft.Windows.RemoteAttestation.Core.TcgEventLog]::Parse($LogBytes)
$ParsedTCGLog.TcgData.Children | Sort-Object -Property PcrIndex | Group-Object -Property PcrIndex
$XmlWriterSettings = New-Object -TypeName System.Xml.XmlWriterSettings
$XmlWriterSettings.Indent = $True
$TcgContentSettings = New-Object -TypeName Microsoft.Windows.RemoteAttestation.Core.TcgContentSettings
$XmlWriter = [Xml.XmlWriter]::Create("$PWD\parsed_tcg_log.xml", $XmlWriterSettings)
$ParsedTCGLog.ToXml($XmlWriter, $TcgContentSettings)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment