Power shell to script tables and procedures (with dependencies) and permissions


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.

script_object_and_permissions.ps1

Comments (1)

  1. Kenneth Choe says:

    The end result includes table generation script twice for the tables used by views. WithDependencies option does not only calculate dependencies and reorder them, but also add any tables needed. So the resulting script is not runnable. Is there a way to solve this problem?