我已经在没有和使用github 上的Getting Started文档中的 -Force 参数的情况下运行了安装脚本
Install-Module dbatools -Scope CurrentUser
Install-Module dbatools -Scope CurrentUser -Force
此代码适用于我的旧服务器,但不适用于新服务器。
$Params =
@{
Column1 = $Column1;
Column2 = $Column2
}
$InsertQuery =
"
insert into dbo.Table
(
Column1,
Column2
)
values
(
@Column1,
@Column2
)
"
Invoke-DbaQuery -SqlInstance "server" -Database "database" -Query $TableSizeInsertQuery -SqlParameter $Params
我不断收到此错误:
Error connecting to [server]: Cannot find an overload for "SqlCommand" and the argument count: "2". At C:\Users\username\Documents\WindowsPowerShell\Modules\dbatools\1.1.46\allcommands.ps1:92862 char:9
+ throw $records[0]
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (server:String) [], Exception
+ FullyQualifiedErrorId : dbatools_Invoke-DbaQuery
我还运行了这些命令:
Install-Module -Name SqlServer
import-module -name SqlServer
install-module -name dbatools
Import-Module -name dbatools