Reputation: 9285
I follow this MSDN article to alter an existing stored procedure with PowerShell:
https://msdn.microsoft.com/en-us/library/ms162190.aspx
(No need to read that)
Inside this example the following line throws an error:
$sp = New-Object -TypeName Microsoft.SqlServer.Management.SMO.StoredProcedure -argumentlist $db, "GetUserPhoneForService"
The error is
New-Object : The type [Microsoft.SqlServer.Management.SMO.StoredProcedure] cannot be found. Be sure you loaded the assembly containing this type.
(I translated the error message from German. So the wording might be a bit different)
Other database actions like simple updates work without any problem.
Upvotes: 0
Views: 134
Reputation: 24071
You need to load the Sql Powershell provider. Use Get-Module -ListAvailable
to see all the offered modules. Load the sqlps with Import-Module
like so,
import-module sqlps
Upvotes: 1