< Back

Get-DbaDbLogShipError

Mon Jan 13, 2020 10:43 am

NAME Get-DbaDbLogShipError



SYNOPSIS

Get-DbaDbLogShipError returns all the log shipping errors that occurred





SYNTAX

Get-DbaDbLogShipError [-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>

[[-SqlCredential] <Pscredential>] [[-Database] <System.String[]>] [[-ExcludeDatabase] <System.String[]>]

[[-Action] <System.String[]>] [[-DateTimeFrom] <Datetime>] [[-DateTimeTo] <Datetime>] [-Primary <Switch>]

[-Secondary <Switch>] [-EnableException <Switch>] [<CommonParameters>]





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.





PARAMETERS

-Action [<System.String[]>]

Filter to get the log shipping action that has occurred like Backup, Copy, Restore.

By default all the actions are returned.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Database [<System.String[]>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-DateTimeFrom [<Datetime>]

Filter the results based on the date starting from datetime X



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-DateTimeTo [<Datetime>]

Filter the results based on the date ending with datetime X



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



-ExcludeDatabase [<System.String[]>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Primary [<Switch>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Secondary [<Switch>]

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



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 [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]

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

Server version 2000 or greater.



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: LogShipping

Author: Sander Stad (@sqlstad), sqlstad.nl



Website: https://dbatools.io

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

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



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



RELATED LINKS

https://dbatools.io/Get-DbaDbLogShipError