---
title: "Update-DbaMaintenanceSolution"
description: "Updates existing Ola Hallengren Maintenance Solution stored procedures to the latest version"
url: "https://dbatools.io/Update-DbaMaintenanceSolution/"
availability: "Windows, Linux, macOS"
tags: ["Community", "OlaHallengren"]
author: "Andreas Jordan, @JordanOrdix"
source: "https://github.com/dataplat/dbatools/blob/master/public/Update-DbaMaintenanceSolution.ps1"
last_updated: "2024-01-01"
---

# Update-DbaMaintenanceSolution

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

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

```

## Examples

### Example 1: Updates Ola Hallengren&#39;s Solution objects on RES14224 in the DBA database

```powershell
PS C:\> Update-DbaMaintenanceSolution -SqlInstance RES14224 -Database DBA
```

### Required Parameters

##### -SqlInstance

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

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

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| 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.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value | master |

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

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value | All |
| Accepted Values | All,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.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -Force

Suppresses confirmation prompts for compatibility with earlier versions.  
The maintenance solution source is refreshed on every invocation, so Force is no longer required to bypass a cached copy.

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

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value | False |

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

| Property | Value |
| --- | --- |
| Alias | wi |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -Confirm

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

| Property | Value |
| --- | --- |
| Alias | cf |
| Required | False |
| Pipeline | false |
| Default Value |  |

## Outputs

**PSCustomObject**

Returns one object per maintenance solution procedure updated. The command will attempt to update all specified solution components (or all components if -Solution is not specified), returning status for each attempt.

**Properties:**

- ComputerName: The computer name of the SQL Server instance
- InstanceName: The SQL Server instance name
- SqlInstance: The full SQL Server instance name (computer\instance)
- Solution: The maintenance solution component name (CommandExecute, Backup, IntegrityCheck, or IndexOptimize)
- Procedure: The name of the stored procedure being updated
- IsUpdated: Boolean indicating if the procedure was successfully updated
- Results: Status or error message. Possible values: "Updated", "Procedure not installed", "File not found", or an error object if the update failed

---

Part of [dbatools](https://dbatools.io/), a free and open source PowerShell module for SQL Server administration. Full command index: https://dbatools.io/commands/
