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.
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:
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?
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):
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.
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.