This is a PowerShell script that can be used to dump out a database schema to a text file (similar to the Generate Scripts option in SSMS).
I wrote it to dump out out live DB schemas which are not under source control (our dev schemas are).
We run the scripts once a week.
They are very useful when someone accidently overwrites say a stored procedure on the live server.
To run from the command line...
Powershell.exe -File "C:\PowerShell\Output_Schema.ps1" - $SQLInstance localhost\sqlexpress - $Output_Folder_Name "D:\Reports\Schema Dumps" - $Database Accounts_Database
In this example, the above script (Output_Schema.ps1) is placed in the folder c:\PowerShell the output text file is written to the folder D:\Reports\Schema Dumps and the database to use is Accounts_Database.
NOTE: The database parameter is optional, if omitted, then all databases on the server will documented.
A text file per database is generated.