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.
5 に答える
Andre Viot のブログによると:
$adapters=(gwmi win32_networkadapterconfiguration )
Foreach ($adapter in $adapters){
Write-Host $adapter
$adapter.settcpipnetbios(0)
}
すべてのアダプタで Netbios を無効にする必要があります。ただし、より慎重になりたい場合は、適切なインターフェイスで Netbios を無効にしていることを確認してください。そのため、最初に を実行Get-WmiObject Win32_NetworkAdapterConfiguration | Where IPAddress
して、現在接続されているアダプターのリストを表示します。
ServiceName DHCPEnabled Index Description
----------- ----------- ----- -----------
VMSMP True 14 Intel Wireless Adapter
VMSMP True 29 Intel Ethernet Adapter
このように、Where オブジェクトに提供されているフィルターを使用して、無効にするものを選択します。LAN で NetBios をオフにしたいです。
$adapter = Get-WmiObject Win32_NetworkAdapterConfiguration | Where Description -like "*Ethernet*"
$adapter.SetTcpIPNetbios(0) | Select ReturnValue
ReturnValue
-----------
0
ただし、WHOLE ロットなど、考えられるリターン コードは多数あります。こちらのリストを確認してください。また、この機能がすべてのデバイスで機能すると怠惰に想定しないでください。最初にこれを確実にテストし、影響を理解する必要があります。
http://www.alexandreviot.net/2014/10/09/powershell-disable-netbios-interface/
接続されていないアダプタで NetBIOS の構成を設定しようとしている場合は、SetTcpIPNetbios を直接使用する代わりに、レジストリの設定を変更できます。
各アダプタ ポート (16 個あります) を反復処理し、すべてのポートで NetBIOS をオフにします。
$i = 'HKLM:\SYSTEM\CurrentControlSet\Services\netbt\Parameters\interfaces'
Get-ChildItem $i | ForEach-Object {
Set-ItemProperty -Path "$i\$($_.pschildname)" -name NetBiosOptions -value 2
}
TcpipNetbiosOptions
次のコマンドを使用して、null 以外のプロパティを持つ各ネットワーク アダプターの NetBIOS ステータスを取得します。
Get-CimInstance -ClassName 'Win32_NetworkAdapterConfiguration' | Where-Object -Property 'TcpipNetbiosOptions' -ne $null | Select-Object -Property @('ServiceName', 'Description', 'TcpipNetbiosOptions');
各ネットワーク アダプタについて、値 は1
NetBIOS が有効であることを2
示し、値 は NetBIOS が無効であることを示します。
TcpipNetbiosOptions
次のコマンドを使用して、null 以外のプロパティを持つ各ネットワーク アダプターの NetBIOS を無効にします。
Get-CimInstance -ClassName 'Win32_NetworkAdapterConfiguration' | Where-Object -Property 'TcpipNetbiosOptions' -ne $null | Invoke-CimMethod -MethodName 'SetTcpipNetbios' -Arguments @{ 'TcpipNetbiosOptions' = [UInt32](2) } -Confirm;
この-Confirm
パラメーターは、変更ごとに確認を必要とします。これは、複数のネットワーク アダプターがあり、そのうちの一部の NetBIOS ステータスのみを変更したい場合に役立ちます。パラメータを削除して、以前に表示されたすべてのネットワーク アダプタの-Confirm
NetBIOS を無効にするだけで、プロセスが高速になります。
値のリストReturnValue
が表示されます。のReturnValue
値は0
、操作が成功したことを示します。最初のコマンドを再度実行して、各ネットワーク アダプタの NetBIOS ステータスを確認します。
マイクロソフトの公式ドキュメント:
- https://docs.microsoft.com/powershell/scripting/learn/deep-dives/everything-about-null
- https://docs.microsoft.com/powershell/module/microsoft.powershell.core/where-object
- https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/select-object
- https://docs.microsoft.com/powershell/module/cimcmdlets/get-ciminstance
- https://docs.microsoft.com/powershell/module/cimcmdlets/invoke-cimmethod
- https://docs.microsoft.com/windows/win32/cimwin32prov/win32-networkadapterconfiguration
- https://docs.microsoft.com/windows/win32/cimwin32prov/settcpipnetbios-method-in-class-win32-networkadapterconfiguration