我正在尝试使用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")}