Author | Kirill Kravtsov (@nvarscar), nvarscar.wordpress.com |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Update-DbaInstance on GitHub.
Want to see the Bill Of Health for this command? Check out Update-DbaInstance.
Installs SQL Server Service Packs and Cumulative Updates across local and remote instances automatically.
Automates the complete process of applying SQL Server patches to eliminate the manual effort of updating multiple instances. This function handles the entire patching workflow from detection through installation, replacing the tedious process of manually downloading, transferring, and applying updates across your SQL Server environment.
The patching process includes:
This replaces the manual process of RDP'ing to each server, copying patch files, running installers, and tracking which systems need which updates. Perfect for monthly patching cycles, emergency security updates, or bringing development environments up to production patch levels.
The impact of this function is set to High. Use -Confirm:$false to suppress interactive prompts for automated deployments.
For CredSSP authentication, the function automatically configures PowerShell remoting when credentials are provided. This can be disabled by setting dbatools configuration 'commands.initialize-credssp.bypass' to $true. CredSSP configuration requires running from an elevated PowerShell session.
Always backup databases and configurations before applying any SQL Server updates.
Update-DbaInstance
[[-ComputerName] <DbaInstanceParameter[]>]
[-Credential <PSCredential>]
[-Version <String[]>]
[-Type <String[]>]
[-InstanceName <String>]
[-Path <String[]>]
[-Restart]
[-Continue]
[-Throttle <Int32>]
[-Authentication <String>]
[-ExtractPath <String>]
[-ArgumentList <String[]>]
[-Download]
[-NoPendingRenameCheck]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Update-DbaInstance
[[-ComputerName] <DbaInstanceParameter[]>]
[-Credential <PSCredential>]
-KB <String[]>
[-InstanceName <String>]
[-Path <String[]>]
[-Restart]
[-Continue]
[-Throttle <Int32>]
[-Authentication <String>]
[-ExtractPath <String>]
[-ArgumentList <String[]>]
[-Download]
[-NoPendingRenameCheck]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
PS C:\> Update-DbaInstance -ComputerName SQL1 -Version SP3 -Path \\network\share
Updates all applicable SQL Server installations on SQL1 to SP3.
Binary files for the update will be searched among all files and folders recursively in \network\share.
Prompts for confirmation before the update.
PS C:\> Update-DbaInstance -ComputerName SQL1, SQL2 -Restart -Path \\network\share -Confirm:$false
Updates all applicable SQL Server installations on SQL1 and SQL2 with the most recent patch (that has at least a "CU" flag).
It will install latest ServicePack, restart the computers, install latest Cumulative Update, and finally restart the computer once again.
Binary files for the update will be searched among all files and folders recursively in \network\share.
Does not prompt for confirmation.
PS C:\> Update-DbaInstance -ComputerName SQL1 -Version 2012 -Type ServicePack -Path \\network\share
Updates SQL Server 2012 on SQL1 with the most recent ServicePack found in your patch repository.
Binary files for the update will be searched among all files and folders recursively in \network\share.
Prompts for confirmation before the update.
PS C:\> Update-DbaInstance -ComputerName SQL1 -KB 123456 -Restart -Path \\network\share -Confirm:$false
Installs KB 123456 on SQL1 and restarts the computer.
Binary files for the update will be searched among all files and folders recursively in \network\share.
Does not prompt for confirmation.
PS C:\> Update-DbaInstance -ComputerName Server1 -Version SQL2012SP3, SQL2016SP2CU3 -Path \\network\share -Restart -Confirm:$false
Updates SQL 2012 to SP3 and SQL 2016 to SP2CU3 on Server1. Each update will be followed by a restart.
Binary files for the update will be searched among all files and folders recursively in \network\share.
Does not prompt for confirmation.
PS C:\> Update-DbaInstance -ComputerName Server1 -Path \\network\share -Restart -Confirm:$false -ExtractPath "C:\temp"
Updates all applicable SQL Server installations on Server1 with the most recent patch. Each update will be followed by a restart.
Binary files for the update will be searched among all files and folders recursively in \network\share.
Does not prompt for confirmation.
Extracts the files in local driver on Server1 C:\temp.
PS C:\> Update-DbaInstance -ComputerName Server1 -Path \\network\share -ArgumentList "/SkipRules=RebootRequiredCheck"
Updates all applicable SQL Server installations on Server1 with the most recent patch.
Additional command line parameters would be passed to the executable.
Binary files for the update will be searched among all files and folders recursively in \network\share.
PS C:\> Update-DbaInstance -ComputerName SQL1 -Version CU3 -Download -Path \\network\share -Confirm:$false
Downloads an appropriate CU KB to \network\share and installs it onto SQL1.
Does not prompt for confirmation.
Installs a specific Knowledge Base update or list of updates by KB number.
Use this when you need to apply a particular security patch or bug fix identified by Microsoft.
Accepts formats like 123456 or KB123456, and supports multiple KB numbers for batch installations.
Alias | |
Required | True |
Pipeline | false |
Default Value |
Target computer with SQL instance or instances.
Alias | cn,host,Server |
Required | False |
Pipeline | true (ByValue) |
Default Value | $env:COMPUTERNAME |
Windows Credential with permission to log on to the remote server.
Must be specified for any remote connection if update Repository is located on a network folder.
Authentication will default to CredSSP if -Credential is used.
For CredSSP see also additional information in DESCRIPTION.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Defines the target SQL Server version level to reach using pattern
Use this to standardize SQL Server instances to a specific patch level across your environment.
Examples: 2008R2SP1 (SQL 2008R2 to SP1), 2016CU3 (SQL 2016 to CU3), SP1CU7 (all versions to SP1 then CU7).
When omitted, installs the latest available patches for each detected SQL Server version.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Specifies which types of SQL Server updates to install: All, ServicePack, or CumulativeUpdate.
Use this when you want to apply only specific update types, such as installing only Service Packs during maintenance windows.
Defaults to All, which installs both Service Packs and Cumulative Updates in proper sequence.
Alias | |
Required | False |
Pipeline | false |
Default Value | @('All') |
Accepted Values | All,ServicePack,CumulativeUpdate |
Limits patching to a specific named SQL Server instance on the target computer.
Use this when you have multiple SQL instances and need to patch only one, such as updating a development instance while leaving production untouched.
Omit this parameter to update all SQL Server instances found on the target computers.
Alias | Instance |
Required | False |
Pipeline | false |
Default Value |
Specifies the folder path containing SQL Server update files for installation.
Use this to point to your centralized patch repository where you store downloaded SQL Server updates.
Files must follow Microsoft's naming pattern (SQLServer####-KB###-x##*.exe) and path must be accessible from both client and target servers.
Configure a default path with Set-DbatoolsConfig -Name Path.SQLServerUpdates to avoid specifying this repeatedly.
Alias | |
Required | False |
Pipeline | false |
Default Value | (Get-DbatoolsConfigValue -Name 'Path.SQLServerUpdates') |
Automatically restarts the server after successful patch installation and waits for it to come back online.
Required for chaining multiple updates since SQL Server patches mandate a restart between installations.
Use this during planned maintenance windows when you can afford server downtime for complete patch sequences.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Resumes a previously failed SQL Server update installation from where it left off.
Use this when a patch installation was interrupted due to network issues, timeouts, or other temporary failures.
Without this switch, the function will abort and clean up any failed installation attempts.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Controls the maximum number of servers that can be updated simultaneously during parallel operations.
Use a lower value (5-10) for large production environments to limit network load and system resource usage.
Defaults to 50, but consider your network bandwidth and the number of concurrent patch installations your infrastructure can handle.
Alias | |
Required | False |
Pipeline | false |
Default Value | 50 |
Specifies the PowerShell remoting authentication method for connecting to remote SQL Server hosts.
Defaults to CredSSP when using -Credential to avoid double-hop authentication issues with network patch repositories.
Use CredSSP when your patch files are stored on network shares that require credential delegation to remote servers.
Alias | |
Required | False |
Pipeline | false |
Default Value | @('Credssp', 'Default')[$null -eq $Credential] |
Accepted Values | Default,Basic,Negotiate,NegotiateWithImplicitCredential,Credssp,Digest,Kerberos |
Specifies the directory on target servers where SQL Server patch files will be extracted before installation.
Use this to control where temporary installation files are placed, especially on servers with limited C: drive space.
Defaults to system temporary directory if not specified, but consider using a dedicated drive with sufficient space.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Passes additional command-line parameters to the SQL Server patch installer executable.
Use this to customize installation behavior such as skipping specific validation rules or running in quiet mode.
Common examples include /SkipRules=RebootRequiredCheck to bypass reboot checks, or /Q for silent installation.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Automatically downloads missing SQL Server update files from Microsoft when they're not found in your patch repository.
Use this to ensure patches are available during installation without manually downloading them beforehand.
Files download to your local temp folder first, then get distributed to target servers or directly to network paths.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Bypasses the check for pending file rename operations that typically require a reboot before patching.
Use this in environments where you're confident no pending renames exist or when system monitoring tools show false positives.
Exercise caution as installing patches with pending renames can lead to installation failures.
Alias | |
Required | False |
Pipeline | false |
Default Value | (Get-DbatoolsConfigValue -Name 'OS.PendingRename' -Fallback $false) |
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 |
Shows what would happen if the command were to run. No actions are actually performed.
Alias | wi |
Required | False |
Pipeline | false |
Default Value |
Prompts you for confirmation before executing any changing operations within the command.
Alias | cf |
Required | False |
Pipeline | false |
Default Value |