

To target unexplained wealth and recover proceeds of corruption and otherĬrimes. Husband of a magnificent woman, father of 5, SQL Server geek, IndyPASS Vice President and Food Guy, DBA automation zealot, amateur Powershell evangelist.Provides a comprehensive guide to illicit enrichment laws and their application # output all the databases as a table for viewing pleasure # add the iDatabase object to the array of iDatabase objects " CheckDB could not be determined for $instance.$database " | Write-Host -ForegroundColor Red ExecuteWithResults ( ' dbcc dbinfo() with tableresults ' ). # executes dbcc dbinfo on database and narrows by dbi_dbcclastknowngood $iDatabase = "" | SELECT InstanceName, DatabaseName, LastSuccessfulCheckDB # create object with all string properties StatementTimeout = $QueryTimeoutįoreach ( $Database in $srv. " Instance Unavailable - Could Not connect to $instance. # How many seconds to wait for instance to respond " Connecting to $instance " | Write-Host -ForegroundColor Blue $iDatabases = Loop over each instance providedįoreach ( $instance in $( get-content $InstanceList )) # Initialize Array to hold new database objects :: LoadWithPartialName ( ' ' ) | Out-Null $InstanceList = " C:\Users\kneier\Documents\Powershell\InstanceList.txt " # $InstanceList file should be a file of SQL instances in either server, server,port or server\instancename # Reports on the last successful checkdb for all databases within all instances provided # Author: Kyle Neier, Perpetual Technologies In this example, however, it just sends all the rows unfiltered to the Format-Table cmdlet.īe certain to vote for the Microsoft Connect suggestion if you think that this would be a valuable addition to the SMO database class. This array could be piped to the ConvertTo-HTML or the ConvertTo-CSV cmdlet to create a more flexible output or even through the Where-Object to only report on those that were out of spec. This script uses a very simple custom object - $iDatabase - and loads these objects up into an array for further processing later.

The script below will give you the last successful checkdb for all databases in any instances that you provide in a text file. I eventually just reverted to T-SQL and the ExecuteWithResults database method to return the DBCC DBINFO result set to Powershell for each database. I knew I had to do something so that Lord Vader wouldn't smack me with the dark side of the force. I filed a Microsoft Connect in December, 2011 that requested to have this feature added to the SMO database class - but that has yet to be responded to by Microsoft. I can get the LastBackupDate, LastLogBackupDate, and LastDifferentalBackupDate as properties of the database class, however LastSuccessfulIntegrit圜heck is just not there. Much to my chagrin, SMO does not expose this property. I recently worked on a project where I needed to have Powershell collect this date. If we kept record of this, we could know exactly to when we would have to restore to be guaranteed a consistent database. This was a tremendous help to me and other DBAs as we could now tell when the integrity was valid on our databases.
IDATABASE REVIEW HOW TO
A few years ago, I wrote a script that was published on about how to verify the last successful CheckDB for all the databases on an instance.
