UPDATE:
I was able to get this done meanwhile. Have used the code in this thread http://social.technet.microsoft.com/Forums/en-US/customization/thread/ec095751-5df1-4b2a-8438-b0fdfcc7e0d5 as a reference and modified it a bit to build the script.
Cheers
Alex