Author | Stuart Moore (@napalmgram), stuart-moore.com |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Read-DbaTransactionLog on GitHub.
Want to see the Bill Of Health for this command? Check out Read-DbaTransactionLog.
Reads the live Transaction log from specified SQL Server Database
Using the fn_dblog function, the live transaction log is read and returned as a PowerShell object
This function returns the whole of the log. The information is presented in the format that the logging subsystem uses.
A soft limit of 0.5GB of log as been implemented. This is based on testing. This limit can be overridden
at the users request, but please be aware that this may have an impact on your target databases and on the
system running this function
Read-DbaTransactionLog
[-SqlInstance] <DbaInstanceParameter>
[[-SqlCredential] <PSCredential>]
[-Database] <Object>
[-IgnoreLimit]
[[-RowLimit] <Int32>]
[-EnableException]
[<CommonParameters>]
PS C:\> $Log = Read-DbaTransactionLog -SqlInstance sql2016 -Database MyDatabase
Will read the contents of the transaction log of MyDatabase on SQL Server Instance sql2016 into the local PowerShell object $Log
PS C:\> $Log = Read-DbaTransactionLog -SqlInstance sql2016 -Database MyDatabase -IgnoreLimit
Will read the contents of the transaction log of MyDatabase on SQL Server Instance sql2016 into the local PowerShell object $Log, ignoring the recommendation of not returning more that 0.5GB of log
The target SQL Server instance or instances
Alias | |
Required | True |
Pipeline | false |
Default Value |
Database to read the transaction log of
Alias | |
Required | True |
Pipeline | false |
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 |
Switch to indicate that you wish to bypass the recommended limits of the function
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Will limit the number of rows returned from the transaction log
Alias | |
Required | False |
Pipeline | false |
Default Value | 0 |
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 |