commands

^

Get-DbaDbLogShipError

Author Sander Stad (@sqlstad), sqlstad.nl
Availability Windows, Linux, macOS

 

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

Synopsis

Get-DbaDbLogShipError returns all the log shipping errors that occurred

Description

When your log shipping fails it's sometimes hard to see why is fails. Using this function you'll be able to find out what went wrong in a short amount of time.

Syntax

Get-DbaDbLogShipError
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [[-Database] <String[]>]
    [[-ExcludeDatabase] <String[]>]
    [[-Action] <String[]>]
    [[-DateTimeFrom] <DateTime>]
    [[-DateTimeTo] <DateTime>]
    [-Primary]
    [-Secondary]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaDbLogShipError -SqlInstance sql1

Get all the log shipping errors that occurred

Example: 2
PS C:\> Get-DbaDbLogShipError -SqlInstance sql1 -Action Backup

Get the errors that have something to do with the backup of the databases

Example: 3
PS C:\> Get-DbaDbLogShipError -SqlInstance sql1 -Secondary

Get the errors that occurred on the secondary instance.
This will return the copy of the restore actions because those only occur on the secondary instance

Example: 4
PS C:\> Get-DbaDbLogShipError -SqlInstance sql1 -DateTimeFrom "01/05/2018"

Get the errors that have occurred from "01/05/2018". This can also be of format "yyyy-MM-dd"

Example: 5
PS C:\> Get-DbaDbLogShipError -SqlInstance sql1 -Secondary -DateTimeFrom "01/05/2018" -DateTimeTo "2018-01-07"

Get the errors that have occurred between "01/05/2018" and "01/07/2018".
See that is doesn't matter how the date is represented.

Required Parameters

-SqlInstance

The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or greater.

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

Allows you to filter the results to only return the databases you're interested in. This can be one or more values separated by commas. This is not a wildcard and should be the exact database name. See examples for more info.

Alias
Required False
Pipeline false
Default Value
-ExcludeDatabase

Allows you to filter the results to only return the databases you're not interested in. This can be one or more values separated by commas. This is not a wildcard and should be the exact database name.

Alias
Required False
Pipeline false
Default Value
-Action

Filter to get the log shipping action that has occurred like Backup, Copy, Restore. By default all the actions are returned.

Alias
Required False
Pipeline false
Default Value
Accepted Values Backup,Copy,Restore
-DateTimeFrom

Filter the results based on the date starting from datetime X

Alias
Required False
Pipeline false
Default Value
-DateTimeTo

Filter the results based on the date ending with datetime X

Alias
Required False
Pipeline false
Default Value
-Primary

Allows to filter the results to only return values that apply to the primary instance.

Alias
Required False
Pipeline false
Default Value False
-Secondary

Allows to filter the results to only return values that apply to the secondary instance.

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