# this is where the PowerShell operational log stores its settings $Path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\winevt\Channels\Microsoft-Windows-PowerShell/Operational"
# get the default SDDL security definition for the classic security log $sddlSecurity = ((wevtutil gl security) -like'channelAccess*').Split(' ')[-1]
# get the current SDDL security for the PowerShell log $sddlPowerShell = (Get-ItemProperty-Path$Path).ChannelAccess
# store the current SDDL security (just in case you want to restore it later) $existsBackup = Test-Path-Path$Path if (!$existsBackup) { Set-ItemProperty-Path$Path-Name ChannelAccessBackup -Value$sddlPowerShell }
# set the hardened security to the PowerShell operational log Set-ItemProperty-Path$Path-Name ChannelAccess -Value$sddlSecurity
# restart the service to take effect Restart-Service-Name EventLog -Force