Disable IPV6 on all adapters with power shell

In the past, I encountered an issue where I needed to disable IPv6 on several workstations in our local network, which had over 1000 devices. Manually disabling IPv6 for each device was impractical, so I sought a way to
automate the process and make remote changes efficiently.

Thankfully, Microsoft provides an extensive Network library in PowerShell that can help solve this type of problem. Now, let’s open the Integrated Scripting Environment (ISE) and get started with the script. The goal is
to disable IPv6 on LAN adapters while keeping WAN or wireless adapters unchanged.

To focus only on LAN adapters, I utilized a variable called $adapter that allows you to specify a keyword for filtering purposes. Here’s the result of my efforts, and comments are included throughout the script to explain
each step.

I hope this script proves useful in your own network management tasks. Enjoy!

 $adapter="*"
 # you can specify what type of adapter you want to make changes to like Wireless or Wired
 # depending on adapter name or use * for all
 $adapters = Get-NetAdapter -name $adapter
 Write-Host "Found $($adapters.Length) adapters"
 foreach ($adapter in $adapters){
     $adName = $adapter.Name
     Write-Host "Working on: $adName"
     $adBindings = Get-NetAdapterBinding -name $adName
     foreach ($adbind in $adBindings){
        Write-Host $adbind.ComponentID
        if ($adbind.ComponentID -eq "ms_tcpip6" -and $adbind.Enabled -eq $true){
           Write-Host "Disabling IPv6 on $adName"
           Set-NetAdapterBinding -Name $adName -ComponentID ms_tcpip6 -Enabled $false
        }
     }
 }

As you can see this is a very basic script to disables IPv6 on specified network adapters within the local machine. The script utilizes two primary functions: Get-NetAdapter and Get-NetAdapterBinding.

1. `Get-NetAdapter -name $adapter`: This command retrieves a list of active network adapters based on the specified name or keyword ($adapter). If you don’t specify any name, it will return all adapters (as indicated by
the use of the wildcard character “*”).

2. `Get-NetAdapterBinding -name $adName`: This command retrieves information about the bound components for the specified adapter (indicated by $adName). It returns a list containing various details, including the component ID and enabled status of each bound component.

The script then iterates through each adapter found, checks if it has IPv6 binding enabled, and if so, disables it using `Set-NetAdapterBinding`. The filtering for specific adapters is done using the variable $adapter, which can
be set to a specific name (like “Wireless” or “Ethernet”) or “*” for all adapters.

Overall, this script simplifies the process of disabling IPv6 on network adapters in bulk, saving time and effort compared to doing it manually for each device.

Note:

To find more options for Set-NetAdapterBinding you can use the Get-NetAdapterBinding PowerShell command.