Invoke-Sqlcmd : Invalid object name 'ServerHotList' Exception

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

Viewing 1 reply thread
  • 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
      Moderator
      Topics: 3
      Replies: 167
      Points: 879
      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.

Viewing 1 reply thread
  • The topic ‘Invoke-Sqlcmd : Invalid object name 'ServerHotList' Exception’ is closed to new replies.