Skip to content

Instantly share code, notes, and snippets.

@mdehaas
Created May 29, 2024 07:40
Show Gist options
  • Save mdehaas/a6a66a06704a9191652c4c63601b6090 to your computer and use it in GitHub Desktop.
Save mdehaas/a6a66a06704a9191652c4c63601b6090 to your computer and use it in GitHub Desktop.
Disable MAC address randomization on Windows 11
$WhatIf = $false
$Verbose = $true
$Debug = $false
$RegPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}"
### END CONFIG #####
$WiFi = Get-NetAdapter -Name "Wi-Fi"
$Keys = Get-ItemProperty -Path "$RegPath\*" -Name "DriverDesc" -ErrorAction SilentlyContinue
foreach ($Key in ($Keys | Where-Object {$_.DriverDesc -eq $WiFi.InterfaceDescription})) {
If ($Key.DriverDesc -eq $WiFi.InterfaceDescription){
$WiFi.InterfaceDescription
"$RegPath\$($Key.PSChildName)"
New-ItemProperty -Path "$RegPath\$($Key.PSChildName)" -Name "NetworkAddress" -Value $($WiFi.MacAddress) -PropertyType String -Force -WhatIf:$WhatIf -Verbose:$Verbose | Out-Null
if ($Debug) {Get-ItemProperty -Path "$RegPath\$($Key.PSChildName)" -Name "NetworkAddress"}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment