I created a detection and remediation script pair for use in Intune to check if the registry-value has changed at boot.
If it does, it immediately changes the value and reboots - before a user can log in.
That way, Start 3 stays that way, without jumping to Start 4 and killing the wifi again.
This works even without admin rights, as I run the script with SYSTEM rights.
Enjoy.
====================================================================================
remediation.ps1
$scriptPath = "C:\Scripts\Check-WinHttpStart.ps1"
Zorg dat de map bestaat
if (-not (Test-Path "C:\Scripts")) {
New-Item -Path "C:\Scripts" -ItemType Directory -Force | Out-Null
}
Maak het control script aan (indien nog niet aanwezig)
$scriptContent = @'
$regPath = "HKLM:\SYSTEM\CurrentControlSet\Services\WinHttpAutoProxySvc"
$currentValue = Get-ItemPropertyValue -Path $regPath -Name Start -ErrorAction SilentlyContinue
if ($currentValue -ne 3) {
Set-ItemProperty -Path $regPath -Name Start -Value 3
Restart-Computer -Force
}
'@
if (-not (Test-Path $scriptPath)) {
$scriptContent | Set-Content -Path $scriptPath -Encoding UTF8
}
Verwijder eventueel oude taak
Unregister-ScheduledTask -TaskName "CheckWinHttpStart" -Confirm:$false -ErrorAction SilentlyContinue
Maak nieuwe scheduled task aan
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-ExecutionPolicy Bypass -WindowStyle Hidden -File "$scriptPath""
$trigger = New-ScheduledTaskTrigger -AtStartup
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest
Register-ScheduledTask -TaskName "CheckWinHttpStart" -Action $action -Trigger $trigger -Principal $principal -Settings (New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -StartWhenAvailable -DontStopIfGoingOnBatteries -Hidden -DisallowStartOnRemoteAppSession) -Force
=================================================
detection.ps1
if (Test-Path "C:\Scripts\Check-WinHttpStart.ps1") {
Write-Host "Script aanwezig"
exit 0
} else {
Write-Host "Script ontbreekt"
exit 1
}
=================================================