Reputation: 39
I am trying to connect to a database using a connection string and run a .sql script.
While trying to run:
Invoke-Sqlcmd -ConnectionString $CString -InputFile .\deleteOldData.sql
I got this error:
A parameter cannot be found that matches parameter name 'ConnectionString'
The Microsoft documentation has -ConnectionString listed as a part of Invoke-Sqlcmd so I'm confused why the command is not working.
Upvotes: 2
Views: 9769
Reputation: 1634
The module SQLPS
has an Invoke-Sqlcmd
which does not have a -ConnectionString
parameter. There is also an Invoke-Sqlcmd
in the SqlServer
module.
Install-Module -Name SqlServer
See this documention for more details.
SQLPS: The SQLPS module is included with the SQL Server installation (for backward compatibility), but is no longer being updated. The most up-to-date PowerShell module is the SqlServer module.
Upvotes: 4