Thor Logo dbatools

Update-DbaMaintenanceSolution

View Source
Andreas Jordan, @JordanOrdix
Windows, Linux, macOS

Synopsis

Updates existing Ola Hallengren Maintenance Solution stored procedures to the latest version

Description

Updates the stored procedures for Ola Hallengren’s Maintenance Solution on SQL Server instances where it’s already installed. This function downloads the latest version from GitHub and replaces only the procedure code, leaving all existing tables, jobs, and configurations intact.

Use this when you need to get bug fixes or improvements in the maintenance procedures without disrupting your existing backup, integrity check, and index optimization jobs. The function checks for existing procedures before attempting updates and only updates what’s currently installed.

This approach only works when the new procedure versions are compatible with your existing table structures and job configurations. If Ola releases changes that require schema modifications or new tables, you’ll need to use Install-DbaMaintenanceSolution for a complete reinstallation instead.

Syntax

Update-DbaMaintenanceSolution
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [[-Database] <String>]
    [[-Solution] <String[]>]
    [[-LocalFile] <String>]
    [-Force]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Update-DbaMaintenanceSolution -SqlInstance RES14224 -Database DBA

Updates Ola Hallengren’s Solution objects on RES14224 in the DBA database.

Required Parameters

-SqlInstance

The target SQL Server instance onto which the Maintenance Solution will be updated.

PropertyValue
Alias
RequiredTrue
Pipelinetrue (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.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-Database

Specifies the database containing the existing Ola Hallengren maintenance solution stored procedures. Defaults to master.
Change this if you installed the maintenance solution in a different database like DBA or Admin.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Valuemaster
-Solution

Controls which maintenance solution components to update. Valid options are All, Backup, IntegrityCheck, IndexOptimize, or CommandExecute.
Use this when you only want to update specific procedures instead of the entire solution. Only procedures that already exist will be updated.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueAll
Accepted ValuesAll,Backup,IntegrityCheck,IndexOptimize,CommandExecute
-LocalFile

Path to a local zip file containing Ola Hallengren’s maintenance solution instead of downloading from GitHub.
Use this in environments without internet access or when you need to deploy a specific version that differs from the latest release.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-Force

Forces download of the latest maintenance solution from GitHub even if a cached version exists locally.
Use this when you want to ensure you’re getting the absolute latest version or if the cached version is corrupted.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-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.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-WhatIf

If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.

PropertyValue
Aliaswi
RequiredFalse
Pipelinefalse
Default Value
-Confirm

If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.

PropertyValue
Aliascf
RequiredFalse
Pipelinefalse
Default Value