Hi everyone,
I am getting this error message:
Invoke-Sqlcmd : Invalid object name 'ServerHotList'. At line:11 char:1 + Invoke-Sqlcmd -ServerInstance $dbAddress -InputFile $CleanDbScriptPath + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Invoke-Sqlcmd], SqlPowerShellSqlExecutionException + FullyQualifiedErrorId : SqlError,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand
Any idea how to avoid it? many thanks in advance,
my code is:
[pre]
cls
$dbAddress = “SEH05VVM745”
$CleanDbScriptPath = “D:\AUTOMATION\Scripts\CleanDB.txt”
$CleanDB = “D:\AUTOMATION\Results\CleanedDBTables.txt”
$TablesDbScriptPath = “D:\AUTOMATION\Scripts\TablesDB.txt”
$ImportedFiles = “D:\AUTOMATION\Results\ImportedTables.txt”
#clean db
Invoke-Sqlcmd -ServerInstance $dbAddress -InputFile $CleanDbScriptPath
Invoke-Sqlcmd -ServerInstance $dbAddress -InputFile $TablesDbScriptPath | Out-File -FilePath $CleanDB
Write-Host “The DB has been cleaned” -ForegroundColor Magenta
[/pre]
Result:
Invoke-Sqlcmd : Invalid object name 'ServerHotList'. At line:11 char:1 + Invoke-Sqlcmd -ServerInstance $dbAddress -InputFile $CleanDbScriptPath + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Invoke-Sqlcmd], SqlPowerShellSqlExecutionException + FullyQualifiedErrorId : SqlError,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand