@exit /b

:fconf:
$fps = @(1,2,3,4,5,6,7,8,11,12,13,14)
$fKeyFM = 'HKLM:\SYSTEM\CurrentControlSet\Control\FeatureManagement\Overrides\'
$fKey10 = 'HKLM:\SYSTEM\CurrentControlSet\Policies\Microsoft\FeatureManagement\Overrides'
$TN = "ReconcileFeatures"; $TP = "\Microsoft\Windows\Flighting\FeatureConfig\"
function Native
{
$t = [AppDomain]::CurrentDomain.DefineDynamicAssembly((Get-Random), 1).DefineDynamicModule((Get-Random), $False).DefineType((Get-Random))
$t.DefinePInvokeMethod('RtlQueryFeatureConfiguration', 'ntdll.dll', 22, 1, [Int32], @([UInt32], [UInt32], [UInt64].MakeByRefType(), [UInt32[]]), 1, 3).SetImplementationFlags(128)
$t.DefinePInvokeMethod('RtlQueryFeatureConfigurationChangeStamp', 'ntdll.dll', 22, 1, [UInt64], @(), 1, 3).SetImplementationFlags(128)
$t.DefinePInvokeMethod('RtlSetFeatureConfigurations', 'ntdll.dll', 22, 1, [Int32], @([UInt64].MakeByRefType(), [UInt32], [Byte[]], [Int32]), 1, 3).SetImplementationFlags(128)
$Win32 = $t.CreateType()
}
function RunTask
{
try {$task = Get-ScheduledTask $TN $TP -ErrorAction Stop} catch {return}
$null = Enable-ScheduledTask $TN $TP
Start-ScheduledTask $TN $TP; while ((Get-ScheduledTask $TN $TP).State.value__ -eq 4) {start-sleep -sec 1}
}
function Clear($fID, $fReg)
{
try {
$fInfo = [UInt32[]]::new(3)
$nRet = $Win32::RtlQueryFeatureConfiguration([UInt32]$fID, 1, [ref]$null, $fInfo)
if ($nRet -eq 0) {$fPriority = ($fInfo[1] -band 0xF)} else {return}
} catch {return}
if ($fPriority -eq 0 -Or $fPriority -eq 9 -Or $fPriority -eq 15) {return}
[byte[]]$fcon = [BitConverter]::GetBytes([UInt32]$fID) + [BitConverter]::GetBytes($fPriority) + [BitConverter]::GetBytes(0) + [BitConverter]::GetBytes(0) + [BitConverter]::GetBytes(0) + [BitConverter]::GetBytes(0) + [BitConverter]::GetBytes(0) + [BitConverter]::GetBytes(4)
try {[UInt64]$fccs = $Win32::RtlQueryFeatureConfigurationChangeStamp()} catch {[UInt64]$fccs = 0}
try {$nRet = $Win32::RtlSetFeatureConfigurations([ref]$fccs, 1, $fcon, 1)} catch {}
$fps | foreach {Remove-Item ($fKeyFM + $_ + '\' + $fReg) -Force -EA 0}
$null = Remove-ItemProperty $fKey10 $fReg -Force -EA 0
return
}
. Native
function Clean
{
Clear 58675091 "653262991"
Clear 60057432 "2963396238"
Clear 61590854 "2381686926"
Clear 61870936 "2957614734"
Clear 62857393 "1647280271"
Clear 63736907 "2541184654"
RunTask
}
:fconf:
