< Back

Get-DbaMaintenanceSolutionLog

Mon Jan 13, 2020 11:15 am

NAME Get-DbaMaintenanceSolutionLog



SYNOPSIS

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





SYNTAX

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

[[-SqlCredential] <Pscredential>] [[-LogType] <System.String[]>] [[-Since] <Datetime>] [[-Path] <String>]

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





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.





PARAMETERS

-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



-LogType [<System.String[]>]

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

available



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Path [<String>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Since [<Datetime>]

Consider only files generated since this date



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.



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: Community, OlaHallengren

Author: Klaas Vandenberghe (@powerdbaklaas) | Simone Bizzotto ( @niphlod )



Website: https://dbatools.io

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

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



https://ola.hallengren.com



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



RELATED LINKS

https://dbatools.io/Get-DbaMaintenanceSolutionLog