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

  • Found the link regarding database corruption

    http://www.sqlskills.com/blogs/paul/teched-demo-corruptions-fatal-to-dbcc-checkdb/

    The second example produces no output if you run integrity 'with no_infomsgs'. Although in this circumstance the database is so corrupt it would be unusable, I am just playing safe. Not all of our databases that I have to monitor are used on a regular basis.

    I have just over 200 databases to monitor. This is why the script I am making reduces the result files by just looking for certain entries on each line to just important messages. The actual output is kept for reference. The reduced result is emailed and the title is based on whether an error occured or not.

    For info...

    I look for lines starting: "checkdb found" and "dbcc execution completed" which are the good messages.

    I also look for lines starting: "database '$($dbName)' cannot" which is bad (and changes the $ErrorOccured flag).

    I also look for lines containing: "corrupt" and "prevent further" which are also bad (again, changes $ErrorOccured).