is there a way to debug veeam powershell scripts?
I am trying to restore a sql server db to another server but I get always the error "Restore-VESQLDatabase : Failed to get access to <servername>."
Code: Select all
Add-PSSnapin VeeamPSSnapin
connect-vbrserver -server "veeamserver" -user 'veeamserver\veeamremoteuser' -password 'anything'
#Variables
$RestoreDate = Get-Date -format dd/MM/yyyy-HH:mm:ss
$ServerName = "sqlserver"
$InstanceName = " " # If you have default instance, use " "
$DatabaseName = "database"
$restorepoint = Get-VBRApplicationRestorePoint -SQL
$sessions = Start-VESQLRestoreSession -RestorePoint $restorepoint[$restorepoint.length-1]
$database = Get-VESQLDatabase -Session $sessions[0] -Name "database"
$dbfiles = Get-VESQLDatabaseFile -Database $database
#$restorepoint = Get-VBRApplicationRestorePoint -SQL
# Start-VESQLRestoreSession -RestorePoint $restorepoint[0]
$secpasswd = ConvertTo-SecureString 'passwordfortargetserver' -AsPlainText -Force
$oscreds = New-Object System.Management.Automation.PSCredential -ArgumentList 'sqlserver\administrator', $secpasswd
$secpasswd = ConvertTo-SecureString 'passwordforsqlserveruser' -AsPlainText -Force
$sqlcreds = New-Object System.Management.Automation.PSCredential -ArgumentList 'dbrestoreuser', $secpasswd
Restore-VESQLDatabase -Database $database -ServerName "sqlserver" -InstanceName " " -TargetFolder "S:\SQL Server Data" -force -GuestCredentials $oscreds -UseSQLAuthentication -SqlCredentials $sqlcreds -verbose
#Stop the connection
Disconnect-VBRServer | out-null
Regards
Marcus