如何使用sql server smo对象的invoke命令

时间:2014-09-30 14:48:47

标签: sql-server powershell smo

我正在尝试使用invoke命令连接到数据库服务器来备份数据库,但它无法连接到服务器测试失败。

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoExtended") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoEnum") | Out-Null

$server = New-Object ("Microsoft.SqlServer.Management.Smo.Server") "test"

当我从本地运行

时,它工作正常
$server = New-Object ("Microsoft.SqlServer.Management.Smo.Server") "(local)"

我正在使用此调用命令

invoke-command -computername test {&("c:\backup.ps1")}

0 个答案:

没有答案