dbatools is a free PowerShell module with over 180 SQL Server administration, best practice and migration commands included.


Read-DbaTransactionLog

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.

Screenshots

Examples

Will read the contents of the transaction log of MyDatabase on SQL Server Instance sql2016 into the local PowerShell object $Log.

$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, ignoring the recommendation of not returning more that 0.5GB of log.

$Log = Read-DbaTransactionLog -SqlInstance sql2016 -Database MyDatabase -IgnoreLimit

Author

This command was created by Stuart Moore. You can find Stuart on Twitter and his blog.

Get-Help

From PowerShell, execute Get-Help Read-DbaTransactionLog -Detailed for more information on this function.

Source Code

Want to see the source code? View Read-DbaTransactionLog.ps1 on GitHub
 

Related commands