I wish to 'generate scripts' from a database in sql using powershell and save the TSQL to a text file /sql file . In Sql Server Management Studio ( SSMS) it looks like ;
right click db , "tasks', 'generate scripts' , choose 'select specific database objects' , select boxes ' views , stored procedures, user-defined functions' . Then under 'Advanced' , I select Script Object-Level Permissions = True , Script DROP and CREATE = Script DROP and CREATE . I then select , " Save to new query window " and the script is available.
I wish to automate this in a script using powershell .