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

  • That is an interesting output.

    Before (sample):

    DBCC results for 'xxxx'.

    Service Broker Msg 9675, State 1: Message Types analyzed: 14.

    Service Broker Msg 9676, State 1: Service Contracts analyzed: 7.

    Service Broker Msg 9667, State 1: Services analyzed: 4.

    DBCC results for 'sys.sysrscols'.

    There are 20881 rows in 250 pages for object "sys.sysrscols".

    DBCC results for 'sys.sysrowsets'.

    There are 3435 rows in 44 pages for object "sys.sysrowsets".

    DBCC results for 'sys.sysclones'.

    There are 0 rows in 0 pages for object "sys.sysclones".

    Your suggestion:

    Error Level State MessageText RepairLevel Status DbId DbFragId ObjectId IndexId

    ----- ----- ----- ----------- ----------- ------ ---- -------- -------- -------

    8997 10 1 Service Broker Msg 9675, State 1: Message Types analyzed: 14. 0 7 1 0 -1

    8997 10 1 Service Broker Msg 9676, State 1: Service Contracts analyzed: 7. 0 7 1 0 -1

    8997 10 1 Service Broker Msg 9667, State 1: Services analyzed: 4. 0 7 1 0 -1

    2593 10 1 There are 20881 rows in 250 pages for object "sys.sysrscols". 0 7 1 3 1

    2593 10 1 There are 3435 rows in 44 pages for object "sys.sysrowsets". 0 7 1 5 1

    2593 10 1 There are 0 rows in 0 pages for object "sys.sysclones". 0 7 1 6 1

    Too much info but I looked up the ft -AutoSize (hadn't used it before) and changed it to 'ft MessageText -HideTableHeaders' and this reduced it back to the info I required.

    Now

    Service Broker Msg 9675, State 1: Message Types analyzed: 14.

    Service Broker Msg 9676, State 1: Service Contracts analyzed: 7.

    Service Broker Msg 9667, State 1: Services analyzed: 4.

    There are 20881 rows in 250 pages for object "sys.sysrscols".

    There are 3435 rows in 44 pages for object "sys.sysrowsets".

    There are 0 rows in 0 pages for object "sys.sysclones".

    I can easily trim the lines I need when read it in again. Now to test it against the test corrupt databases to check i still get the error messages. I recall (can't link it) an article that recommended using the 'with all_errormsgs' because if the database is so corrupt, it wouldn't produce an output (which makes it look like all is well when used with 'with no_infomsgs'). Wonder how this will output.

    Many thanks, especially as I have learnt about Format-Tables. It is always a good day when you learn something, especially for an accidental DBA like me.