Kill All Connections For Domain Account Users
When you want users out of the database, do you have a timeframe as to when they should be allowed back in? The script you have above, will get rid of the users, but those users can just create a new connection to the database. What will you do when the user reconnects? Do you need to keep them out of the database for the entire time of the maintenance? What is the goal with keeping the users out of the database during the maintenance?

Additionally, if you kick people off out of the database, are you ok with losing the transaction that may be in flight?

What kind of maintenance do you want to do the database? Is it being done during a time of day when users should not be using the database?