Files
Tanium/Packages/RegistryOnHKLM/DisableWPAD.ps1
2025-10-31 08:59:02 +01:00

23 lines
901 B
PowerShell

$ErrorActionPreference = 'Stop'
$isOS64 = [Environment]::Is64BitOperatingSystem
$isProc64 = [Environment]::Is64BitProcess
$KeyPS = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp'
$KeyRel = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp'
$Name = 'DisableWpad'
if ($isOS64 -and -not $isProc64) {
# 32-bit PowerShell on 64-bit OS -> write to 64-bit registry view
$bk = [Microsoft.Win32.RegistryKey]::OpenBaseKey(
[Microsoft.Win32.RegistryHive]::LocalMachine,
[Microsoft.Win32.RegistryView]::Registry64
)
$k = $bk.CreateSubKey($KeyRel)
$k.SetValue($Name, 1, [Microsoft.Win32.RegistryValueKind]::DWord)
$k.Close()
} else {
if (-not (Test-Path -LiteralPath $KeyPS)) { New-Item -Path $KeyPS -Force | Out-Null }
New-ItemProperty -Path $KeyPS -Name $Name -Value 1 -PropertyType DWord -Force | Out-Null
}