Last active
March 30, 2022 14:03
-
-
Save peyton2465/9af6d1be7e5499016a8cc8d69e19e4c4 to your computer and use it in GitHub Desktop.
Mac Address Randomizer for Windows (requires admin)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Output "Randomizing Macs" | |
$DeviceTypes = @{ | |
"Wi-Fi" = $true; | |
"Ethernet" = $true; | |
} | |
$SelectedDevices = @{} | |
foreach ($device in (Get-NetAdapter | Where-Object {$DeviceTypes[$_.Name] -and $_.Status -ne "Disabled"}).InterfaceDescription) { | |
$SelectedDevices.Add($device, $true) | |
} | |
$Devices = [Microsoft.Win32.RegistryKey]::OpenBaseKey("LocalMachine", "Registry64").OpenSubKey("SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\", $true) | |
foreach ($deviceName in $Devices.GetSubKeyNames()) { | |
try { $device = $Devices.OpenSubKey($deviceName, $true) } catch { continue } | |
$deviceDesc = $device.GetValue("DriverDesc") | |
if ($null -ne $deviceDesc -and $SelectedDevices[$deviceDesc]) { | |
$device.SetValue("NetworkAddress", "02" + ([BitConverter]::ToString([BitConverter]::GetBytes((Get-Random -Maximum 0xFFFFFFFFFFFF)), 0, 5).Replace('-', ''))) | |
Disable-NetAdapter -InterfaceDescription $deviceDesc -Confirm:$False | |
Enable-NetAdapter -InterfaceDescription $deviceDesc -Confirm:$False | |
} | |
} | |
Write-Output "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment