I want to modify the below to script stored procedures. I replaced (tables with SP) but apparently the syntax is wrong. Also, I'd like to be able to run below for a specific (Schema.SP). Any help is much appreciated.
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | out-null
$MyScripter=new-object ("Microsoft.SqlServer.Management.Smo.Scripter")
$srv=New-Object "Microsoft.SqlServer.Management.Smo.Server" "Server\database"
$MyScripter.Server=$srv
$so=$MyScripter.Options
$so.FileName="C:\Database\SCRIPTS\PowerShell\SharedDimensions\filename.sql"
$MyScripter.Script($srv.Databases["adventureworks"].tables)
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | out-null
$MyScripter=new-object ("Microsoft.SqlServer.Management.Smo.Scripter")
$srv=New-Object "Microsoft.SqlServer.Management.Smo.Server" "Server\database"
$MyScripter.Server=$srv
$so=$MyScripter.Options
$so.FileName="C:\Database\SCRIPTS\PowerShell\SharedDimensions\filename.sql"
$MyScripter.Script($srv.Databases["adventureworks"].tables)