Home Forums Programming Powershell Integrity check output to file using Invoke-Sqlcmd failing RE: Integrity check output to file using Invoke-Sqlcmd failing

  • Tableresults seems to work:

    Invoke-Sqlcmd -Query "dbcc checkdb(N'$($dbName)') WITH ALL_ERRORMSGS, TABLERESULTS" | ft -AutoSize | Out-File "$($ResultFile)"

    Interestingly, the Database class includes methods for Check Alloc, Catalog, and Table, but not an overall CHECKDB. So I think Invoke-SqlCmd might be the only way to achieve this.