commands

^

Get-DbaMaintenanceSolutionLog

Author Klaas Vandenberghe (@powerdbaklaas) , Simone Bizzotto ( @niphlod )
Availability Windows, Linux, macOS

 

Synopsis

Reads the log files generated by the IndexOptimize Agent Job from Ola Hallengren's MaintenanceSolution.

Description

Ola wrote a .sql script to get the content from the commandLog table. However, if LogToTable='N', there will be no logging in that table. This function reads the text files that are written in the SQL Instance's Log directory.

Syntax

Get-DbaMaintenanceSolutionLog
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [[-LogType] <String[]>]
    [[-Since] <DateTime>]
    [[-Path] <String>]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaMaintenanceSolutionLog -SqlInstance sqlserver2014a

Gets the outcome of the IndexOptimize job on sql instance sqlserver2014a.

Example: 2
PS C:\> Get-DbaMaintenanceSolutionLog -SqlInstance sqlserver2014a -SqlCredential $credential

Gets the outcome of the IndexOptimize job on sqlserver2014a, using SQL Authentication.

Example: 3
PS C:\> 'sqlserver2014a', 'sqlserver2020test' | Get-DbaMaintenanceSolutionLog

Gets the outcome of the IndexOptimize job on sqlserver2014a and sqlserver2020test.

Example: 4
PS C:\> Get-DbaMaintenanceSolutionLog -SqlInstance sqlserver2014a -Path 'D:\logs\maintenancesolution\'

Gets the outcome of the IndexOptimize job on sqlserver2014a, reading the log files in their custom location.

Example: 5
PS C:\> Get-DbaMaintenanceSolutionLog -SqlInstance sqlserver2014a -Since '2017-07-18'

Gets the outcome of the IndexOptimize job on sqlserver2014a, starting from july 18, 2017.

Example: 6
PS C:\> Get-DbaMaintenanceSolutionLog -SqlInstance sqlserver2014a -LogType IndexOptimize

Gets the outcome of the IndexOptimize job on sqlserver2014a, the other options are not yet available! sorry

Required Parameters

-SqlInstance

The target SQL Server instance or 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
-LogType

Accepts 'IndexOptimize', 'DatabaseBackup', 'DatabaseIntegrityCheck'. ATM only IndexOptimize parsing is available

Alias
Required False
Pipeline false
Default Value IndexOptimize
Accepted Values IndexOptimize,DatabaseBackup,DatabaseIntegrityCheck
-Since

Consider only files generated since this date

Alias
Required False
Pipeline false
Default Value
-Path

Where to search for log files. By default it's the SQL instance error log path path

Alias
Required False
Pipeline false
Default Value
-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-DbaMaintenanceSolutionLog on GitHub.
Want to see the Bill Of Health for this command? Check out Get-DbaMaintenanceSolutionLog.