Disable WINS and NetBios over TCP/IP

This topic contains 5 replies, has 3 voices, and was last updated by Profile photo of Ken Resler Ken Resler 8 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #33489
    Profile photo of Ken Resler
    Ken Resler
    Participant

    I need to disable those two protocols on one of two nic's in new servers. I have found this code and will be using most of it for other tasks.
    $nic = Get-WmiObject Win32_NetworkAdapterConfiguration -filter "ipenabled = 'true'"
    $ip_address = Read-Host("What's the IP address? :")
    $subnetMask = Read-Host("what's the subnet mask? :")
    $gateway = Read-Host("what's the gateway? :")
    $nic.EnableStatic($ip_address,$subnetmask)
    $nic.SetGateways($gateway,1)
    $dns = "10.0.0.11","10.0.0.11","10.0.0.12","10.0.0.13"
    $nic.SetDNSServerSearchOrder($dns)
    $nic.SetTcpipNetbios(2)
    $nic.SetDnsDomain("juventus.com")

    I know this this code will look at both nics on my servers because IP is enabled on both. I just need help to limit this action to one nic called heartbeat in the server.

    I have already done a search of the forum and have found no similar posts.

    Thanks
    Ken

    #33493
    Profile photo of tommymaynard
    tommymaynard
    Participant

    Is 'heartbeat' the value stored in the Description property? If so, modify the value provided to the -Filter parameter so that it filters on more than one property:

    Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled = 'true' AND Description = 'heartbeat'"
    
    #33498
    Profile photo of Ken Resler
    Ken Resler
    Participant

    Tommy,

    Thank you for your reply. No that is the name of the NIC. We are renaming the NIC's so could I do this
    Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled = 'true' AND Name = 'heartbeat'"

    I suppose worst case scenario I see with get-netadapter that description is blank so I could probably use set-netadapter?

    #33499
    Profile photo of Christian Sandfeld
    Christian Sandfeld
    Participant

    The logical network adapter name in Windows (which is probably what you have renamed), is not available through the Win32_NetworkAdapterConfiguration WMI class. Instead you can find it in the Win32_NetworkAdapter class.

    Here I get info for my adapter named "Local Area Connection" (the adapter "Name" is in the NetConnectionID property):

    C:\> Get-CimInstance -ClassName Win32_NetworkAdapter -Filter "NetConnectionID = 'Local Area Connection'" -Property *
    
    
    
    Availability                : 3
    Name                        : Intel(R) 82579LM Gigabit Network Connection
    Status                      : 
    StatusInfo                  : 
    DeviceID                    : 7
    Caption                     : [00000007] Intel(R) 82579LM Gigabit Network Connection
    Description                 : Intel(R) 82579LM Gigabit Network Connection
    InstallDate                 : 
    ConfigManagerErrorCode      : 0
    ConfigManagerUserConfig     : False
    CreationClassName           : Win32_NetworkAdapter
    ErrorCleared                : 
    ErrorDescription            : 
    LastErrorCode               : 
    PNPDeviceID                 : PCI\VEN_8086&DEV_1502&SUBSYS_21F317AA&REV_04\3&E89B380&0&C8
    PowerManagementCapabilities : 
    PowerManagementSupported    : False
    SystemCreationClassName     : Win32_ComputerSystem
    SystemName                  : MY-PC-NAME
    AutoSense                   : 
    MaxSpeed                    : 
    NetworkAddresses            : 
    PermanentAddress            : 
    Speed                       : 
    AdapterType                 : Ethernet 802.3
    AdapterTypeId               : 0
    GUID                        : {5739BD3A-1CEF-4698-9D70-EDE11928AA69}
    Index                       : 7
    Installed                   : True
    InterfaceIndex              : 6
    MACAddress                  : 00:00:DE:AD:BE:EF
    Manufacturer                : Intel
    MaxNumberControlled         : 0
    NetConnectionID             : Local Area Connection
    NetConnectionStatus         : 2
    NetEnabled                  : True
    PhysicalAdapter             : True
    ProductName                 : Intel(R) 82579LM Gigabit Network Connection
    ServiceName                 : e1cexpress
    TimeOfLastReset             : 05-01-2016 09:04:46
    PSComputerName              : 
    CimClass                    : root/cimv2:Win32_NetworkAdapter
    CimInstanceProperties       : {Caption, Description, InstallDate, Name...}
    CimSystemProperties         : Microsoft.Management.Infrastructure.CimSystemProperties
    

    Armed with the information provided from that class, you could select the appropriate adapter from Win32_NetworkAdapterConfiguration by filtering with the MACAddress, the GUID/SettingID, the Index or whatever you prefer.

    #33507
    Profile photo of tommymaynard
    tommymaynard
    Participant

    I'd agree with Christian. The easiest way to solve this, would be to retrieve a property from the Win32_NetworkAdapter class and use that information as part of your filter when you query your system using the Win32_NetworkAdapterConfiguration class. Here's a simple way to accomplish that goal.

    $MAC = (Get-WmiObject -Class Win32_NetworkAdapter -Filter "NetConnectionID = 'heartbeat'").MACAddress
    Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "MACAddress = '$($MAC)'"
    
    #34389
    Profile photo of Ken Resler
    Ken Resler
    Participant

    Sorry it took me so long but thank this helped. Just wanted you to know.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.