Skip to content

Instantly share code, notes, and snippets.

@p0w3rsh3ll
Created August 4, 2016 16:26
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 p0w3rsh3ll/7a24c4fd1e131ac3023dbbdae3a57768 to your computer and use it in GitHub Desktop.
Save p0w3rsh3ll/7a24c4fd1e131ac3023dbbdae3a57768 to your computer and use it in GitHub Desktop.
Get-WinEvent -FilterHashtable @{
LogName = 'Microsoft-Windows-PowerShell/Operational' ; Id = 4104
} | ForEach-Object {
if (([xml]$_.toXML()).Event.EventData.Data.InnerXml -match '^-----BEGIN CMS-----') {
$_ |
Add-Member -MemberType NoteProperty -Name isProtected -Value $true -PassThru |
Add-Member -MemberType ScriptProperty -Name UnprotectedMessage -Value {
try {
$this.Message | Unprotect-CmsMessage -ErrorAction Stop
} catch {
[string]::Empty
}
} -PassThru
} else {
$_ |
Add-Member -MemberType NoteProperty -Name isProtected -Value $false -PassThru |
Add-Member -MemberType ScriptProperty -Name UnprotectedMessage -Value {
$this.Message
} -PassThru
}
} |
Select Message,TimeCreated,isProtected,UnprotectedMessage |
Out-GridView
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment