The script is available for download from https://gallery.technet.microsoft.com//How-to-grant-permissions-1f1b46e5. You can also use Microsoft Script Browser for Windows PowerShell ISE to download the sample with one button click from within your scripting environment.
This T-SQL script will demo how to grant permissions to a user-defined role and assign the role to some of the users in a specified database.?
As some customers want to know how to grant some permissions to some users, it is better to create a user-defined role and grant it to the users who need the role permission. In this script, users will get all the permission from login except the permission of deleting rows in a table.
You can find more All-In-One Script Framework script samples at https://aka.ms/onescriptingallery