Author | Stuart Moore (@napalmgram), stuart-moore.com |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Get-DbaSchemaChangeHistory on GitHub.
Want to see the Bill Of Health for this command? Check out Get-DbaSchemaChangeHistory.
Retrieves DDL change history from the SQL Server default system trace
Queries the default system trace to track CREATE, DROP, and ALTER operations performed on database objects, providing a complete audit trail of schema modifications. This helps DBAs identify who made changes, when they occurred, and which objects were affected without needing to manually parse trace files or enable custom auditing. Returns detailed information including login names, timestamps, application sources, and operation types for compliance reporting and troubleshooting. Only works with SQL Server 2005 and later, as the system trace didn't exist before then.
Get-DbaSchemaChangeHistory
[-SqlInstance] <DbaInstanceParameter[]>
[[-SqlCredential] <PSCredential>]
[[-Database] <Object[]>]
[[-ExcludeDatabase] <Object[]>]
[[-Since] <DbaDateTime>]
[[-Object] <String[]>]
[-EnableException]
[<CommonParameters>]
PS C:\> Get-DbaSchemaChangeHistory -SqlInstance localhost
Returns all DDL changes made in all databases on the SQL Server instance localhost since the system trace began
PS C:\> Get-DbaSchemaChangeHistory -SqlInstance localhost -Since (Get-Date).AddDays(-7)
Returns all DDL changes made in all databases on the SQL Server instance localhost in the last 7 days
PS C:\> Get-DbaSchemaChangeHistory -SqlInstance localhost -Database Finance, Prod -Since (Get-Date).AddDays(-7)
Returns all DDL changes made in the Prod and Finance databases on the SQL Server instance localhost in the last 7 days
PS C:\> Get-DbaSchemaChangeHistory -SqlInstance localhost -Database Finance -Object AccountsTable -Since (Get-Date).AddDays(-7)
Returns all DDL changes made to the AccountsTable object in the Finance database on the SQL Server instance localhost in the last 7 days
The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.
Alias | |
Required | True |
Pipeline | true (ByValue) |
Default Value |
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Specifies which databases to include when searching for schema changes. Accepts multiple database names and wildcards for pattern matching.
Use this when you need to focus on specific databases instead of scanning all databases on the instance.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Specifies databases to exclude from the schema change search. Accepts multiple database names for filtering out unwanted databases.
Use this to skip system databases, test databases, or any databases you don't want included in the change history results.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Filters results to show only DDL changes that occurred after the specified date and time. Accepts standard PowerShell date formats.
Use this to focus on recent changes or changes within a specific time period, especially helpful for troubleshooting recent issues or compliance reporting.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Specifies the names of specific database objects to search for in the change history. Accepts multiple object names for targeted searches.
Use this when investigating changes to particular tables, views, stored procedures, or other database objects rather than reviewing all schema changes.
Alias | |
Required | False |
Pipeline | false |
Default Value |
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.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |