-
-
Save p0w3rsh3ll/7a24c4fd1e131ac3023dbbdae3a57768 to your computer and use it in GitHub Desktop.
This file contains 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
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