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.
Invokes installation of SQL Server Service Packs and Cumulative Updates on local and remote servers.
Starts an automated process of updating SQL Server installation to a specific version defined in the parameters.
The command will:
The impact of this function is set to High, if you don't want to receive interactive prompts, set -Confirm to $false.
When using CredSSP authentication, this function will try to configure CredSSP authentication for PowerShell Remoting sessions.
If this is not desired (e.g.: CredSSP authentication is managed externally, or is already configured appropriately,)
it can be disabled by setting the dbatools configuration option 'commands.initialize-credssp.bypass' value to $true.
To be able to configure CredSSP, the command needs to be run in an elevated PowerShell session.
Always backup databases and configurations prior to upgrade.
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.
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.
Install a specific update or list of updates. Can be a number of a string KBXXXXXXX.
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 |
A target version of the installation you want to reach. If not specified, a latest available version would be used by default.
Can be defined using the following general pattern:
Any part of the pattern can be omitted if needed:
2008R2SP1 - will update SQL 2008R2 to SP1
2016CU3 - will update SQL 2016 to CU3 of current Service Pack installed
SP0CU3 - will update all existing SQL Server versions to RTM CU3 without installing any service packs
SP1CU7 - will update all existing SQL Server versions to SP1 and then (after restart if -Restart is specified) to SP1CU7
CU7 - will update all existing SQL Server versions to CU7 of current Service Pack installed
Alias | |
Required | False |
Pipeline | false |
Default Value |
Type of the update: All | ServicePack | CumulativeUpdate.
Default: All
Use -Version to limit upgrade to a certain Major version of SQL Server.
Alias | |
Required | False |
Pipeline | false |
Default Value | @('All') |
Accepted Values | All,ServicePack,CumulativeUpdate |
Only updates a specific instance(s).
Alias | Instance |
Required | False |
Pipeline | false |
Default Value |
Path to the folder(s) with SQL Server patches downloaded. It will be scanned recursively for available patches.
Path should be available from both server with SQL Server installation and client that runs the command.
All file names should match the pattern used by Microsoft: SQLServer####-KB###-x##*.exe
If a file is missing in the repository, the installation will fail.
Consider setting the following configuration if you want to omit this parameter: Set-DbatoolsConfig -Name Path.SQLServerUpdates -Value '\\path\to\updates'
Alias | |
Required | False |
Pipeline | false |
Default Value | (Get-DbatoolsConfigValue -Name 'Path.SQLServerUpdates') |
Restart computer automatically after a successful installation of a patch and wait until it comes back online.
Using this parameter is the only way to chain-install more than 1 patch on a computer, since every single patch will require a restart of said computer.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Continues a failed installation attempt when specified. Will abort a previously failed installation otherwise.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Maximum number of computers updated in parallel. Once reached, the update operations will queue up.
Default: 50
Alias | |
Required | False |
Pipeline | false |
Default Value | 50 |
Chooses an authentication protocol for remote connections.
Allowed values: 'Default', 'Basic', 'Negotiate', 'NegotiateWithImplicitCredential', 'Credssp', 'Digest', 'Kerberos'.
If the protocol fails to establish a connection and explicit -Credentials were used, a failback authentication method would be attempted that configures PSSessionConfiguration
on the remote machine. This method, however, is considered insecure and would, therefore, prompt an additional confirmation when used.
Defaults:
Alias | |
Required | False |
Pipeline | false |
Default Value | @('Credssp', 'Default')[$null -eq $Credential] |
Accepted Values | Default,Basic,Negotiate,NegotiateWithImplicitCredential,Credssp,Digest,Kerberos |
Lets you specify a location to extract the update file to on the system requiring the update. e.g. C:\temp
Alias | |
Required | False |
Pipeline | false |
Default Value |
A list of extra arguments to pass to the execution file. Accepts one or more strings containing command line parameters.
Example: ... -ArgumentList "/SkipRules=RebootRequiredCheck", "/Q"
Alias | |
Required | False |
Pipeline | false |
Default Value |
Download missing KBs to the first folder specified in the -Path parameter.
Files would be first downloaded to the local machine (TEMP folder), and then distributed onto remote machines if needed.
If the Path is a network Path, the files would be downloaded straight to the network folder and executed from there.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Disables pending rename validation when checking for a pending reboot.
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 |