Invoke-Sqlcmd : Invalid object name 'ServerHotList' Exception

Welcome Forums General PowerShell Q&A Invoke-Sqlcmd : Invalid object name 'ServerHotList' Exception

This topic contains 1 reply, has 2 voices, and was last updated by

 
Participant
2 weeks, 6 days ago.

  • Author
    Posts
  • #178581

    Participant
    Topics: 4
    Replies: 5
    Points: 57
    Rank: Member

    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:

    
    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
    
    

    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
    
  • #180423

    Participant
    Topics: 1
    Replies: 96
    Points: 514
    Helping Hand
    Rank: Major Contributor

    It looks like ServerHostList is not a valid object (Table, View or SP), i.e., either it doesn't exist or incorrectly spelled, please check.

    Ideally, the SQL scripts end with the .sql extension.

    Thank you.

You must be logged in to reply to this topic.