Scripting Resource Pools and Resource Groups

Unfortunately, SQL Server’s management studio doesn’t provide you with a simple way to script your resource pools and resource groups. If you want to do this you’ll first have to script all the groups, and then the pools one by one in the correct order. To recreate them you have to do the same but in a reverse order.
This SQL script does just that, it generates the scripts needed to recreate your resource groups and pools in the correct order.