The script checks whether users have 1 of these 3 roles in Office 365:

After that, all users are retrieved and then checked for each user if they have an admin role, if not PowerShell disabled.

You could add things yourself.
For example, I have added a distribution group where I can enable users for PowerShell.

See my blog post for more.