Last active
July 11, 2025 15:10
-
-
Save scriptingstudio/f87beb9d46cddf3a82609e2d1dbca04b to your computer and use it in GitHub Desktop.
Work around for a faulty network adapter
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
| #Requires -RunAsAdministrator | |
| <# | |
| There are weird computers having physical netadapters without macaddress. | |
| This script finds faulty netadapters and assigns a random macaddress to the adapter | |
| #> | |
| Get-NetAdapter -Physical -ErrorAction 0 | Where-Object { | |
| $_.InterfaceDescription -notmatch 'Wireless|wi-fi|virt|Hyper-V' -and $_.MacAddress -eq '00-00-00-00-00-00' | |
| } | ForEach-Object { | |
| Write-Warning 'Faulty network adapter found!' | |
| $newmac = (1..6 | ForEach-Object { | |
| '{0:X}{1:X}' -f (Get-Random -Minimum 0 -Maximum 15),(Get-Random -Minimum 0 -Maximum 15) | |
| }) -join '-' | |
| Set-NetAdapter -Name $_.name -MacAddress $newmac -Confirm:$false -ErrorAction 0 #-NoRestart | |
| '{0} :: {1}' -f $_.name, $newmac | Out-File -FilePath $PSScriptRoot\macaddress.txt -Encoding utf8 -Append -Force -ErrorAction 0 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment