functionGet-DbaSuspectPage{<#
.SYNOPSIS
Returns data that is stored in SQL for Suspect Pages on the specified SQL Server Instance

.DESCRIPTION
This function returns any records that were stored due to suspect pages in databases on a SQL Server Instance.

.PARAMETER SqlInstance
The target SQL Server instance or instances

.PARAMETER SqlCredential
A credential to use to connect to the SQL Instance rather than using Windows Authentication

.PARAMETER Database
The database to return. If unspecified, all records will be returned.

.PARAMETER EnableException
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

$sql="Select
DB_NAME(database_id) as DBName,
file_id,
page_id,
CASE event_type
WHEN 1 THEN '823 or 824 or Torn Page'
WHEN 2 THEN 'Bad Checksum'
WHEN 3 THEN 'Torn Page'
WHEN 4 THEN 'Restored'
WHEN 5 THEN 'Repaired (DBCC)'
WHEN 7 THEN 'Deallocated (DBCC)'
END as EventType,
error_count,
last_update_date
from msdb.dbo.suspect_pages"