I'm trying to write a PowerShell script that can disable network adapter bindings, but the adapter names vary from one system to another (e.g., Ethernet, Ethernet 2, etc.). The one thing that stays consistent is the component ID, which is always 'csco_acnamfd'. I want to make sure the script targets all bindings associated with that specific component ID. Does anyone have suggestions on how I can accomplish this?
4 Answers
You should always check the bindings before you set or delete them. It's good practice!
You can use this command to achieve what you need: `Get-NetAdapterBinding -ComponentID csco_acnamfd | Disable-NetAdapterBinding`. It should target all relevant bindings without needing to specify the adapter name.
Shouldn't that binding get removed when you uninstall the associated product?
Yeah, but we're having trouble removing it from some systems.
Are you starting with any script already? If not, consider this approach:
`$allowedEthernetNames = @['Ethernet', 'Ethernet 2', 'Ethernet 3', 'Ethernet 4']`
Then you can filter the bindings like this: `Get-NetAdapterBinding -ComponentID 'csco_acnamfd' | Where-Object {$_.Name -in $allowedEthernetNames} | Disable-NetAdapterBinding`. This way, you'll cover the variations in names.
That does seem to work. Thanks! I was expecting it to ask for a name, but it just goes ahead and disables the bindings.