Hello Srikanth,
Attaching the sample for diabling all users except admin and guest.
Change the query in the code or modify the code as per your requirement.
Yes, I had tested the delete bulk users in my environment, but you still need to rely on your testings.
Thanks,
Prithvi