If you want to Delete multiple devices from Domain by using a script. Then you can do it with the help of Qapp.
Firstly, you need to create a Qapp and in the Canvas itself you need to add “Script”.
In that “Script” you can use our in-build function known as DeleteDevices. To import that function in your script and using it, you need to do as below:-
from netbrain.sysapi.datamodel import DeleteDevices DeleteDevices(list_of_device_name)
Noted: The input given to this function should be in the list format. e.g [device1, device2, device3]
Once, the devices are deleted from Domain. They can only be re-added by performing the Discovery Task again.
For me, this would a bit dangerous though, I prefer to implement a step for a manual check in between. Create a list of dismantled/removed devices (hostnames) from your asset management or CMDB. Create a dedicated Device Group and use the Add Devices To Group API to fill the group. Check the contents of the group before right-clicking to Remove from Domain. Or map the devices and do some reachability tests before removing.