asnp "VeeamPSSnapIn" -ErrorAction SilentlyContinue
$VCVMName = "vcenter01.lab.local"
$serverName = "$env:computername\VEEAM"
$databaseName = "VeeamBackup"
$vc = Find-VBRViEntity -Name $VCVMName | ?{$_.Reference -notlike "vm-*"}
$conn = New-Object System.Data.SQLClient.SQLConnection
$conn.ConnectionString = "Server=$serverName;Database=$databaseName;Integrated Security=SSPI;"
$cmd = New-Object System.Data.SQLClient.SQLCommand
$cmd.Connection = $conn
$cmd.CommandText = "UPDATE [BObjects] set host_id = '$($vc.ConnHost.Id)',
object_id = '$($vc.Reference)',
path = '$($vc.Path)' WHERE object_name = '$VCVMName' AND object_id NOT LIKE 'vm%'"
try
{
$conn.Open()
}
catch
{
Write-Warning "Couldn't open connection"
break
}
try
{
$cmd.ExecuteNonQuery() | Out-Null
}
catch
{
Write-Warning "Update failed"
}
finally
{
$conn.Close()
}
$serverName = "$env:computername\VEEAM"
$databaseName = "VeeamBackup"
ThomasMc wrote:I've never tested it on Win 2008 but that should cause us any issues, points of interest on the script are
- Code: Select all
$serverName = "$env:computername\VEEAM"
$databaseName = "VeeamBackup"
try
{
$conn.Open()
}
catch
{
Write-Warning "Couldn't open connection"
break
}
try
{
$conn.Open()
}
catch
{
"Error: $_"
break
}
"Error: Exception calling "Open" with "0" argument(s): "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 25 - Connection string is not valid)Users browsing this forum: No registered users and 2 guests