I have an ethernet adapter and a wireless adapter and can't for the life of me figure out the command line (or powershell) used to disable Netbios over TCP/IP for all the adapters on a system. I would appreciate any input on this.
-
You might get a better response on [ServerFault](http://serverfault.com/). – Élie Dec 21 '15 at 00:21
-
This is a question for [SuperUser](https://superuser.com/), not for ServerFault (or StackOverflow). On second thought, it's actually a question for Google. – Ansgar Wiechers Dec 21 '15 at 00:29
5 Answers
According to Andre Viot's blog:
$adapters=(gwmi win32_networkadapterconfiguration )
Foreach ($adapter in $adapters){
Write-Host $adapter
$adapter.settcpipnetbios(0)
}
Should disable Netbios on EVERY adapter. You might wish to be more discerning, and be sure you're disabling Netbios on the right interface, however, so I would first run Get-WmiObject Win32_NetworkAdapterConfiguration | Where IPAddress
, to see a list of your adapters which are currently connected.
ServiceName DHCPEnabled Index Description
----------- ----------- ----- -----------
VMSMP True 14 Intel Wireless Adapter
VMSMP True 29 Intel Ethernet Adapter
Select the one you want to disable using a filter provided to Where Object, like this. I want to turn off NetBios on my LAN.
$adapter = Get-WmiObject Win32_NetworkAdapterConfiguration | Where Description -like "*Ethernet*"
$adapter.SetTcpIPNetbios(0) | Select ReturnValue
ReturnValue
-----------
0
There are a number of possible return codes though, like a WHOLE lot. Make sure to check the list here, and do not lazily assume that the function will work on every device. You should definitely test this first and understand the ramifications.
http://www.alexandreviot.net/2014/10/09/powershell-disable-netbios-interface/

- 12,569
- 2
- 33
- 48
-
5`SetTcpipNetbios(0)` == enable NetBIOS via DHCP. `SetTcpNetbios(2)` disables it. Also, it would make sense to filter the list for IP-enabled adapters first. – Ansgar Wiechers Dec 21 '15 at 09:59
-
Thank you. I was looking on google before and nothing was working. I didn't realize that it had so many elements to it. – DDJ Dec 21 '15 at 15:40
-
Unfortunately, .SetTcpipNetbios(2) does not work when the network adapter does not currently have an active network connection (it returns 84, “IP not enabled on adapter”), so it is impossible to disable NetBIOS this way before connecting to the network. Does anyone know another way which would work even before the network connection is established? – Sergey Vlasov Jan 13 '18 at 14:11
If you are trying to set the configuration of NetBIOS on an adapter that has no connection, you can change the settings in the registry instead of directly using SetTcpIPNetbios.
I iterate through each of the adapter ports (I have 16) and then turn NetBIOS off on all of them:
$i = 'HKLM:\SYSTEM\CurrentControlSet\Services\netbt\Parameters\interfaces'
Get-ChildItem $i | ForEach-Object {
Set-ItemProperty -Path "$i\$($_.pschildname)" -name NetBiosOptions -value 2
}

- 98
- 5
From other answers and comment about, I use this as one line command to disable NetBIOS:
(Get-WmiObject Win32_NetworkAdapterConfiguration -Filter IpEnabled="true").SetTcpipNetbios(2)

- 101
- 2
As WMI v1 cmdlets were removed in PowerShell 6, the "modern way" to do this is through CIM cmdlets, with an example from powershell.one:
# define the arguments you want to submit to the method
# remove values that you do not want to submit
# make sure you replace values with meaningful content before running the code
# see section "Parameters" below for a description of each argument.
$arguments = @{
TcpipNetbiosOptions = [UInt32](12345) # replace 12345 with a meaningful value
}
# select the instance(s) for which you want to invoke the method
# you can use "Get-CimInstance -Query (ADD FILTER CLAUSE HERE!)" to safely play with filter clauses
# if you want to apply the method to ALL instances, remove "Where...." clause altogether.
$query = 'Select * From Win32_NetworkAdapterConfiguration Where (ADD FILTER CLAUSE HERE!)'
Invoke-CimMethod -Query $query -Namespace Root/CIMV2 -MethodName SetTcpipNetbios -Arguments $arguments |
Add-Member -MemberType ScriptProperty -Name ReturnValueFriendly -Passthru -Value {
switch ([int]$this.ReturnValue)
{
0 {'Successful completion, no reboot required'}
1 {'Successful completion, reboot required'}
64 {'Method not supported on this platform'}
65 {'Unknown failure'}
66 {'Invalid subnet mask'}
67 {'An error occurred while processing an Instance that was returned'}
68 {'Invalid input parameter'}
69 {'More than 5 gateways specified'}
70 {'Invalid IP address'}
71 {'Invalid gateway IP address'}
72 {'An error occurred while accessing the Registry for the requested information'}
73 {'Invalid domain name'}
74 {'Invalid host name'}
75 {'No primary/secondary WINS server defined'}
76 {'Invalid file'}
77 {'Invalid system path'}
78 {'File copy failed'}
79 {'Invalid security parameter'}
80 {'Unable to configure TCP/IP service'}
81 {'Unable to configure DHCP service'}
82 {'Unable to renew DHCP lease'}
83 {'Unable to release DHCP lease'}
84 {'IP not enabled on adapter'}
85 {'IPX not enabled on adapter'}
86 {'Frame/network number bounds error'}
87 {'Invalid frame type'}
88 {'Invalid network number'}
89 {'Duplicate network number'}
90 {'Parameter out of bounds'}
91 {'Access denied'}
92 {'Out of memory'}
93 {'Already exists'}
94 {'Path, file or object not found'}
95 {'Unable to notify service'}
96 {'Unable to notify DNS service'}
97 {'Interface not configurable'}
98 {'Not all DHCP leases could be released/renewed'}
100 {'DHCP not enabled on adapter'}
default {'Unknown Error '}
}
}
Note: this needs to be run as administrator.

- 195
- 8
Use the following command to get the NetBIOS status of each network adapter with a non-null TcpipNetbiosOptions
property:
Get-CimInstance -ClassName 'Win32_NetworkAdapterConfiguration' | Where-Object -Property 'TcpipNetbiosOptions' -ne $null | Select-Object -Property @('ServiceName', 'Description', 'TcpipNetbiosOptions');
For each network adapter, a value of 1
indicates that NetBIOS is enabled and a value of 2
indicates that NetBIOS is disabled.
Use the following command to disable NetBIOS for each network adapter with a non-null TcpipNetbiosOptions
property:
Get-CimInstance -ClassName 'Win32_NetworkAdapterConfiguration' | Where-Object -Property 'TcpipNetbiosOptions' -ne $null | Invoke-CimMethod -MethodName 'SetTcpipNetbios' -Arguments @{ 'TcpipNetbiosOptions' = [UInt32](2) } -Confirm;
The -Confirm
parameter requires confirmation for each change, which is helpful if one has multiple network adapters and only wants to change the NetBIOS status for some of them. Remove the -Confirm
parameter to simply disable NetBIOS for all of the previously shown network adapters and thereby make the process faster.
A list of ReturnValue
values should be shown. A ReturnValue
value of 0
indicates that the operation was successful. Run the first command again to confirm the NetBIOS status of each network adapter.
Official Microsoft Documentation:
- https://learn.microsoft.com/powershell/scripting/learn/deep-dives/everything-about-null
- https://learn.microsoft.com/powershell/module/microsoft.powershell.core/where-object
- https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/select-object
- https://learn.microsoft.com/powershell/module/cimcmdlets/get-ciminstance
- https://learn.microsoft.com/powershell/module/cimcmdlets/invoke-cimmethod
- https://learn.microsoft.com/windows/win32/cimwin32prov/win32-networkadapterconfiguration
- https://learn.microsoft.com/windows/win32/cimwin32prov/settcpipnetbios-method-in-class-win32-networkadapterconfiguration

- 2,187
- 1
- 20
- 23