I have two queries that retrieve all groups and all users in a domain, Mydomain
Mydomain
--; Get all groups in domain MyDomain select * from OpenQu
The Microsoft Technet Script Center is a great resource for scripts
http://technet.microsoft.com/en-us/scriptcenter/default.aspx
Here is a script that claims to give out exactly what you want:
http://gallery.technet.microsoft.com/ScriptCenter/en-us/ab5400e2-489a-4738-9b85-508bcb5b75f8