commands

^

Get-DbaDbLogSpace

Author Jess Pomfret, JessPomfret.com
Availability Windows, Linux, macOS

 

Synopsis

Gets information on the database transaction log usage for each instance(s) of SQL Server.

Description

Returns transaction log size and space used for each database on the SQL Server instance(s).

This can be used to monitor how much of your allocated transaction log space is in use, and whether it is nearing the point where it will need to grow.

Syntax

Get-DbaDbLogSpace
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [[-Database] <String[]>]
    [[-ExcludeDatabase] <String[]>]
    [-ExcludeSystemDatabase]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaDbLogSpace -SqlInstance Server1

Returns the transaction log usage information for all databases on Server1

Example: 2
PS C:\> Get-DbaDbLogSpace -SqlInstance Server1 -Database Database1, Database2

Returns the transaction log usage information for both Database1 and Database 2 on Server1

Example: 3
PS C:\> Get-DbaDbLogSpace -SqlInstance Server1 -ExcludeDatabase Database3

Returns the transaction log usage information for all databases on Server1, except Database3

Example: 4
PS C:\> Get-DbaDbLogSpace -SqlInstance Server1 -ExcludeSystemDatabase

Returns the transaction log usage information for all databases on Server1, except the system databases

Example: 5
PS C:\> Get-DbaRegisteredServer -SqlInstance cmsServer | Get-DbaDbLogSpace -Database Database1

Returns the transaction log usage information for Database1 for a group of servers from SQL Server Central Management Server (CMS).

Required Parameters

-SqlInstance

SQL Server name or SMO object representing the SQL Server to connect to. 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

Optional Parameters

-SqlCredential

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
-Database

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
-ExcludeDatabase

The database(s) to exclude - this list is auto-populated from the server.

Alias
Required False
Pipeline false
Default Value
-ExcludeSystemDatabase

Allows you to suppress output on system databases.

Alias
Required False
Pipeline false
Default Value False
-EnableException

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

 

Want to see the source code for this command? Check out Get-DbaDbLogSpace on GitHub.
Want to see the Bill Of Health for this command? Check out Get-DbaDbLogSpace.