How to remove Network Extension in macOS from command line?

I'm developing a network extension and as part of the code/build/test loop I'm scripting removing all installation artifacts.

I haven't been able to figure out how to remove a network extension from script.

I know system extensions use systemextensionsctl but I couldn't find an equivalent.

Answered by gordonfrommilton in 718328022

I discovered the networksetup tool. Example usage:

networksetup -setnetworkserviceenabled "MyTestVPN" off
networksetup -removenetworkservice "MyTestVPN"
networksetup -listallnetworkservices

I figured it out

Accepted Answer

I discovered the networksetup tool. Example usage:

networksetup -setnetworkserviceenabled "MyTestVPN" off
networksetup -removenetworkservice "MyTestVPN"
networksetup -listallnetworkservices

Just as a reference here; Make sure that you are not deleting the Network System Extension from the command line and then re-installing it again. Doing so will cause issues when you want un-install or deactivate the Network System Extension. When removing a Network System Extension it is best practice to either drag the container app to the trash and go through the prompt to remove the extension, or go through the deactivation request process in the container app and then remove the container app by hand. You may just be turning the extension on and off here, but I wanted to mention this to save you future headaches.

How to remove Network Extension in macOS from command line?
 
 
Q