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.
Gets DDL changes logged in the system trace.
Queries the default system trace for any DDL changes in the specified time frame
Only works with SQL 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 |
The database(s) to process - this list is auto-populated from the server. If unspecified, all databases will be processed.
Alias | |
Required | False |
Pipeline | false |
Default Value |
The database(s) to exclude - this list is auto-populated from the server
Alias | |
Required | False |
Pipeline | false |
Default Value |
A date from which DDL changes should be returned. Default is to start at the beginning of the current trace file
Alias | |
Required | False |
Pipeline | false |
Default Value |
The name of a SQL Server object you want to look for changes on
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 |