Disable IPV6 on all adapters with power shell

A few months ago, I faced a challenge where I had to disable IPV6 on the workstations in the local network. This was not an easy task, since there were over 1000 workstations to deal with. Doing it manually for each one was out of the question. I had to find a way to automate the process and apply the changes remotely.
I am sure, someone else ran into this issue before. Looks like good folks at Microsoft have thought of pretty much everything with a very extensive Network library in Power Shell.
Time to open ISE and start writing. Here is the result of my effort. As you can see in the comments, the variable $adapter allows you to put a keyword to focus only on LAN adapters and leave the WAN or wireless adapters unchanged.
I hope you find this script useful.

 $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.
This is how it works:

  • Starts by getting the list of all available adapters.
  • Then one by one and change the ms_tcpip6 setting from enabled to disabled by changing the Enabled value to false.
Note:

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