Overview

13 Install and Update SQL Server

This chapter explains how to install and update SQL Server on Windows from the command line using dbatools, emphasizing why automation matters for modernization, standardization, and security. By replacing manual, GUI-driven steps with scripts, teams gain faster deployments, fewer mistakes, consistent configurations, and simpler maintenance, all while shrinking outage windows. The authors also highlight how automation naturally encourages testing practices and aligns DBAs with DevOps culture.

For installing, the focus is on using Install-DbaInstance, which simplifies both local and multithreaded remote deployments, auto-generates sensible configuration (including optimized tempdb), and supports remote execution from a central workstation. Because remote installs in a domain can be affected by Kerberos double-hop, the chapter outlines practical remedies such as enabling delegation or copying and mounting media, noting delegation is required for many non-engine scenarios. To keep credentials safe, it recommends setting service accounts after installation with Update-DbaServiceAccount and considers managed service accounts for maximum security. Installs can be customized through a configuration file, a PowerShell hashtable, or built-in parameters to control features, paths, collation, authentication, and administrators, with configurations saved to source control. Post-install actions—like security hardening, migrations, maintenance solutions, and availability groups—are likewise automatable to maintain consistency.

For updating, Update-DbaInstance enables remote, large-scale patching with minimal interaction, can auto-detect what each instance needs, and lets you target specific instances or versions. Companion commands such as Get-DbaKbUpdate and Save-DbaKbUpdate streamline discovering and caching installers, and the updater can accept either a specific file or a directory of patches. The chapter underscores the security importance of timely patching, noting common blockers such as fear of breaking systems and the tedium of manual processes; it counters these with test environments, virtualization, and automation to boost confidence and cadence. Overall, dbatools makes installs and patching fast, repeatable, and secure, reducing operational risk while improving DBA efficiency and satisfaction.

Figure 13.1. Several commonly modified attributes as seen in the GUI. Whatever you usually change here, you’ll want to change in your automated install.
setupchanges

Hands-on Lab

Use what you have read about in this chapter by trying the following tasks:

  • Test what would happen if you performed an install using the -WhatIf parameter
  • Do the same with updating a remote instance
  • Get some examples for Update-DbaInstance using Get-Help

FAQ

What’s the preferred way to automate SQL Server installs on Windows with dbatools?Use Install-DbaInstance. It focuses on ease-of-use and remote installs, generates a ConfigurationFile.ini for you (including optimized tempdb settings), supports multithreaded installs (up to 50 at once), and is more flexible and simpler than SysPrep or manually driving setup.exe with a config file.
What are the main benefits of automating SQL Server installs?- Standardization and compliance
- Faster, more consistent deployments with fewer mistakes and one-offs
- Easier maintenance and less downtime (e.g., no data on C:)
- Time savings, better quality, and higher team satisfaction
- Source-controlled install configs and on-demand installs (e.g., via CI/CD)
How do I perform a quick local install, and why isn’t it recommended for production?For a local test install you only need -Path (to setup.exe) and -Version. This default install places everything on C: and enables default features you likely don’t need, so it’s not suited for production. For production, customize features and paths.
How do remote installs work, and how do I handle the Kerberos double-hop issue?Remote installs target domain-joined servers from a central workstation. Address double-hop by enabling delegation (recommended), or by alternatives like CredSSP (use with caution), copy-and-mount the ISO on the target, easing share permissions, or using DSC (runs as SYSTEM). After setting delegation, clear tickets (e.g., KLIST PURGE) or wait/reboot. Use -Throttle to limit concurrent installs.
Should I set service accounts during install or after?By default, Microsoft’s NT Service accounts are used. Supplying credentials during install can expose passwords in plain text on the remote machine and in verbose logs. The safer approach is to install first, then change accounts securely with Update-DbaServiceAccount. Consider using Managed Service Accounts for maximum security.
What’s the difference between -ConfigurationFile and -Configuration?-ConfigurationFile points to a SQL Server ConfigurationFile.ini you maintain (great for full parity with setup.exe options and source control). -Configuration is a PowerShell hashtable equivalent of those options. Both map to setup’s unattended install parameters; choose whichever fits your workflow.
Which built-in parameters should I typically customize?Commonly changed parameters include DataPath, LogPath, TempPath, BackupPath, InstancePath, AdminAccount, and network settings (e.g., enabling TCP). Also consider PerformVolumeMaintenanceTasks for instant file initialization when appropriate.
Can dbatools automate post-install tasks?Yes. Examples include creating Availability Groups (New-DbaAvailabilityGroup), installing Ola Hallengren’s maintenance solution (Install-DbaMaintenanceSolution), performing migrations (Start-DbaMigration), and securely changing service accounts (Update-DbaServiceAccount). Automating post-install steps keeps environments consistent.
How do I automate SQL Server patching with dbatools?Use Update-DbaInstance to patch one or many servers remotely. Point -Path to a specific KB .exe or a directory; the command can auto-detect the correct patch per instance. Limit scope with -InstanceName or -Version, and specify -Type (e.g., CumulativeUpdate) when needed. Find and download updates with Get-DbaKbUpdate and Save-DbaKbUpdate.
Why is patching important, and how do I reduce risk?Patching closes known vulnerabilities; many breaches stem from unpatched software. Reduce risk by testing patches in a representative test domain/environment before production, leveraging automation (Install/Update-DbaInstance) and virtualization. Aim toward CI/CD and routine, automated updates.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Learn dbatools in a Month of Lunches ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Learn dbatools in a Month of Lunches ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Learn dbatools in a Month of Lunches ebook for free