< Back

Read-DbaTransactionLog

Mon Jan 13, 2020 1:07 pm

NAME Read-DbaTransactionLog



SYNOPSIS

Reads the live Transaction log from specified SQL Server Database





SYNTAX

Read-DbaTransactionLog [-SqlInstance] <DbaInstanceParameter> [[-SqlCredential] <Pscredential>] [-Database]

<System.Object> [-IgnoreLimit <Switch>] [[-RowLimit] <Int>] [-EnableException <Switch>] [<CommonParameters>]





DESCRIPTION

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





PARAMETERS

-Database [<System.Object>]

Database to read the transaction log of



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-EnableException [<Switch>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-IgnoreLimit [<Switch>]

Switch to indicate that you wish to bypass the recommended limits of the function



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RowLimit [<Int>]

Will limit the number of rows returned from the transaction log



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlCredential [<Pscredential>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlInstance [<DbaInstanceParameter>]

The target SQL Server instance or instances



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: Database, Log, LogFile

Author: Stuart Moore (@napalmgram), stuart-moore.com



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



-------------------------- EXAMPLE 1 --------------------------



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

-------------------------- EXAMPLE 2 --------------------------



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



RELATED LINKS