Script to change MAC Address on specific adapter

Welcome Forums General PowerShell Q&A Script to change MAC Address on specific adapter

Viewing 13 reply threads
  • Author
    Posts
    • #250598
      Participant
      Topics: 1
      Replies: 5
      Points: 22
      Rank: Member

      Hi experts:

      In my Realtek USB GbE Family Controller adapter, in advanced properties, I can set a value in “Network address”, forcing the adapter to have another MAC Address.

      Is it possible to do this with a PowerShell script or command?

      Thank you very much.

      J.C.

    • #250604
      Participant
      Topics: 15
      Replies: 1776
      Points: 3,218
      Helping Hand
      Rank: Community Hero

      Not sure that is correct. The MAC address is a permanent read-only value set by the manufacturer to provide a unique identifier to a piece of hardware. Most likely you are setting a MAC address spoofing value that the RealTek software sends when communicating with other devices, but it does not change the actual MAC value.

      As far as setting that value with Powershell, it’s most likely in the Registry under the vendor like Software\RealTek. You should just search for the MAC address set and find it.

      • This reply was modified 1 month, 1 week ago by Rob Simmers.
    • #250619
      Participant
      Topics: 1
      Replies: 5
      Points: 22
      Rank: Member

      Thank you Rob, I am aware of that.

      I need that a notebook when connected to a docking pass through a specific MAC address, in order to apply some configurations. This is working but when the adapter driver is updated, this setting is lost. I need a way to set-up this value using a script and not by working in each corporate notebook.

    • #250637
      Participant
      Topics: 8
      Replies: 568
      Points: 2,171
      Helping Hand
      Rank: Community Hero

      The data is stored in the registry as Rob suggests, but they are located in one of the numbered subfolders at the following path

      The best way I’ve found is to search for the appropriate adapter by name. The following code will set the MAC on an Intel NIC. I’ve set it to warn if more than one NIC matches and in that case just refine your search term. I may end up writing a function to make it easier to use. This was tested on an Intel 1219-LM and the property (named “Locally Administered Address” in this case) was updated in device manager instantly. I believe you need to disable/enable or reboot for it to take effect.

      **** DISCLAIMER ****
      Editing the registry directly can have serious, unexpected consequences that can prevent the system from starting and require that you reinstall Windows. It is your responsibility to back up and protect your computer/registry. If you are not familiar with making modifications to the registry, I suggest you do not proceed.

      OK with that out of the way, you can just set your searchterm and your MAC, and this should do the rest.

      Note there should be backticks in front of each single quote around $searchterm and one before nPlease. The forum is not playing nice with them. I’ve also made a gist for convenience.

      https://gist.github.com/krzydoug/1156562d099edb70f2a1aeb423ba0661

    • #250640
      Participant
      Topics: 1
      Replies: 5
      Points: 22
      Rank: Member

      Thank you very much Doug, this is exactly what I was looking for.

    • #250652
      Participant
      Topics: 15
      Replies: 1776
      Points: 3,218
      Helping Hand
      Rank: Community Hero

      Odd, I cannot see Doug(h)’s post that is being reference.

    • #250655
      Participant
      Topics: 8
      Replies: 568
      Points: 2,171
      Helping Hand
      Rank: Community Hero

      It disappeared because I fixed a typo.. you know.

    • #250658
      Participant
      Topics: 1
      Replies: 5
      Points: 22
      Rank: Member

      Me neither! I was going to copy to test it, and it just disappeared…

    • #250661
      Participant
      Topics: 8
      Replies: 568
      Points: 2,171
      Helping Hand
      Rank: Community Hero

      backticks are not working on here, refer to the gist

      https://gist.github.com/krzydoug/1156562d099edb70f2a1aeb423ba0661

    • #250664
      Participant
      Topics: 8
      Replies: 568
      Points: 2,171
      Helping Hand
      Rank: Community Hero

      My other post was more complete, I’m just waiting for mods to reinstate it. It had a disclaimer about modifying the registry as well.

    • #250667
      Participant
      Topics: 1
      Replies: 5
      Points: 22
      Rank: Member

      I found that the network address value is saved in thisĀ  key:

      HKLM – System – CurrentControlSet – Control – Class – {4d36e972-e325-11ce-bfc1-08002be10318] – 0016

      I would not need a PS script if this was a fixed location, but unfortunately the last 4 digits change…

    • #250691
      Participant
      Topics: 15
      Replies: 1776
      Points: 3,218
      Helping Hand
      Rank: Community Hero

      It’s most likely based on the adapter. See if there is an association with Get-NetworkAdapter or WMI Win32_NetworkAdapter. For instance, 16 refers to the device ID, so you would have to find the adapter to find the registry key if you can’t use something generic like ‘intel’ as Doug had done.

    • #250697
      Participant
      Topics: 8
      Replies: 568
      Points: 2,171
      Helping Hand
      Rank: Community Hero

      My script searches for it by name.

    • #250922
      Participant
      Topics: 1
      Replies: 5
      Points: 22
      Rank: Member

      I deployed the script remotely with PDQ Deploy and it works!!! It helps that we have a corporate policy of brand and model so all of our docking stations have the same adapter.

      Thank you Doug and Rob for your time.

      J.C.

Viewing 13 reply threads
  • You must be logged in to reply to this topic.