I have several dozens of non-existent network services that appear in the network panel in System Preferences.
I have generated a list of network services with:
networksetup -listallnetworkservices
## output:
# "Ethernet Adaptor (en12)"
# "Ethernet Adaptor (en13)"
# ...
# "Ethernet Adaptor (en156)"
Now trying to delete a service with e.g.
networksetup -removenetworkservice "Ethernet Adaptor (en156)"
results in the following output:
You cannot remove Ethernet Adaptor (en156) because there aren't any other network services on Ethernet Adaptor (en156).
** Error: The parameters were not valid.
Selecting a service in the Network applet and deleting it by clicking the ➖ button works fine.
Can this be done from the command line?