Start-SqlSetup.ps1 is the headless command-line variant of SQLSetupTool. It installs SQL Server 2019 / 2022 / 2025 on a dbatools basis (Install-DbaInstance) and can optionally run all the way through to an AlwaysOn availability group — no GUI required. It reuses the existing GUI modules unchanged (Config, Validation, DiskLayout, CopySource, Installation, PostInstall, DbaToolsSetup, Drivers, PreInstall) plus sqmSQLTool, and reads the same settings.ini / domain profiles as the GUI — CLI parameters only override individual values for that run.
dbatools and sqmSQLTool reachable (share → local → PSGallery, as configured in settings.ini).<InstallDrive>:\SQLSources\SQL<Version>\SQL_Install (plus \Reporting, \Management, \TDP for optional components) — same as the GUI.FailoverClusters module.:: via the .cmd launcher (checks elevation, forwards all arguments) Start-SqlSetup.cmd -Version 2022 -Edition Developer -NonInteractive :: or directly with PowerShell powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\Start-SqlSetup.ps1 -Version 2022 -NonInteractive
Dry run (recommended before every real run):
Start-SqlSetup.cmd -Version 2025 -Edition Developer-Standard -InstanceName SQL01 -WhatIf
-WhatIf resolves the configuration and paths, prints the installation plan, and runs nothing.
| Parameter | Description | Default |
|---|---|---|
| -ConfigPath | Path to settings.ini | <ScriptDir>\Config\settings.ini |
| -Version | 2019 | 2022 | 2025 | [General] DefaultVersion |
| -Edition | Edition matching the version's edition list (e.g. Developer, Standard, Developer-Standard) | DefaultEdition |
| -InstanceName | MSSQLServer (default instance) or a named instance | DefaultInstanceName |
| -Collation | Server collation | resolved collation |
| -ServiceAccount / -ServicePassword | SQL service account (DOMAIN\User + SecureString) | virtual service account |
| -ServiceCredential | PSCredential (alternative to account/password) | — |
| -InstallDrive / -DataDrive / -LogDrive / -TempDrive / -BackupDrive | Override the disk layout (single letter each) | from disk layout |
| -Component | SSRS,SSAS,SSMS,SSIS,TDP (multi-select) | enabled in settings.ini (SSMS+SSIS on by default) |
| -Driver | JDBC,ODBC,DB2 | enabled ones with a source path |
| -MonitoringType | 0 = none, 1 = service, 2 = full | MonitoringDefault |
| -SkipPreInstall | Skip PreInstall checks (automatic under -NonInteractive) | — |
| -SkipPostInstall | Skip PostInstall | — |
| -AlwaysOn | Create an AG after PostInstall (Invoke-sqmAlwaysOnSetup) | — |
| -AvailabilityGroupName / -AgDatabase / -AgListenerName / -AgListenerIPAddress / -AgListenerPort | AlwaysOn parameters (mostly auto-detected from the cluster) | auto |
| -NonInteractive | Fully unattended, no dialogs | — |
| -LogPath | Directory for the run log | C:\System\WinSrvLog\MSSQL |
| -ProgressReport | Generate an animated HTML run replay | — |
| -ProgressReportPath | Target path for the HTML file | <LogPath>\SqlSetup_<timestamp>.html |
| -WhatIf | Dry run, no changes | — |
Note on PreInstall: Invoke-PreInstallChecks (64K format / snapshot / HPU) uses interactive dialogs and is therefore skipped automatically under -NonInteractive. Run interactively, without -NonInteractive, to get these checks.
Get-SetupConfig (settings.ini + domain profile) — CLI parameters override individual values.Assert-DbaToolsReady / Assert-sqmSQLToolReady.Get-SqlPaths prints the plan (with -WhatIf, this is where it stops).New-SqlDirectories → Invoke-SqlInstallation (= Install-DbaInstance).Invoke-PostInstall (memory/TempDB/ports/monitoring/Ola/...).-AlwaysOn: Invoke-sqmAlwaysOnSetup.SSIS belongs to the engine feature (IS). If SSIS isn't listed in -Component, the CLI removes IS from the feature list — exactly like unchecking the GUI checkbox.
-AlwaysOn calls Invoke-sqmAlwaysOnSetup (module sqmSQLTool), which reads the WSFC and nodes, detects the listener role if not given, checks connectivity (Windows Auth/Kerberos preferred, falling back to -SqlCredential if SPNs are missing), optionally backs up the cluster settings, creates the availability group with automatic seeding, joins secondaries, syncs logins, and can emit an SPN request file for the AD team. Both functions are fully -WhatIf-capable.
AlwaysOn directly, without an install:
Import-Module sqmSQLTool # Full run on the cluster node: Invoke-sqmAlwaysOnSetup -AvailabilityGroupName ProdAG -Database AppDb # Dry run with SQL auth: Invoke-sqmAlwaysOnSetup -AvailabilityGroupName ProdAG -Database AppDb -SqlCredential (Get-Credential sa) -WhatIf # Just the AG core creation, fully parameter-driven: New-sqmAvailabilityGroup -SqlInstance SQL01 -SecondaryReplica SQL02,SQL03 ` -AvailabilityGroupName ProdAG -Database AppDb ` -ListenerName ProdAGL -ListenerIPAddress 10.0.0.50 -ListenerPort 1433 ` -ServiceAccount 'CONTOSO\svcSql'
:: Unattended default instance, SQL 2022 Developer Start-SqlSetup.cmd -Version 2022 -Edition Developer -NonInteractive :: Named instance, SQL 2025, SSMS+SSIS only, ODBC driver, dry run Start-SqlSetup.cmd -Version 2025 -Edition Developer-Standard -InstanceName SQL01 -Component SSMS,SSIS -Driver ODBC -WhatIf :: Install + PostInstall + AlwaysOn AG Start-SqlSetup.cmd -Version 2022 -NonInteractive -AlwaysOn -AvailabilityGroupName ProdAG -AgDatabase AppDb
-WhatIf resolves configuration, paths, and the planned steps without running them. Add -ProgressReport for a replay of the planned run.Get-sqmSQLInstanceCheck green and a PostInstall report generated. Verify SQL 2025 separately.Invoke-sqmAlwaysOnSetup → Get-sqmAlwaysOnHealthReport shows a healthy AG and listener.Invoke-Pester against tests\Unit\Public\New-sqmAvailabilityGroup.Tests.ps1 (15 tests, mocked).Log: every CLI run writes SqlSetupCli_<timestamp>.log to -LogPath (default C:\System\WinSrvLog\MSSQL). PostInstall and AlwaysOn steps additionally log via Invoke-sqmLogging. With -ProgressReport, an event stream (.events.jsonl) and the animated replay (.html) are written alongside it.
| Exit code | Meaning |
|---|---|
| 0 | OK |
| 1 | No admin rights, or configuration missing |
| 2 | Aborted by PreInstall |
| 3 | Installation error |
| 4 | A configured drive is missing |
"Share not reachable": not fatal — the tool falls back to a local install / PSGallery; only the affected sources or features are skipped.
AlwaysOn connection fails: check SPNs (see the generated AD-team file), or pass -SqlCredential for SQL authentication.
Repeatability: every step is idempotent — running it again skips whatever already exists (instance, endpoint, AG, listener).