You can  use Power shell and SMO to script out objects  and its dependents in a database along with object permissions. This blogs entry has a sample power shell script that you can use to generate script in automated way.