powershelldba.de
REF: PSDB-SETUP-CLI-2026 SCOPE: Start-SqlSetup.ps1 STATUS: HEADLESS
CLI

The unattended alternative.

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.

Prerequisites

Before the first run.

Invocation

Always dry-run first.

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

Parameters

Every parameter, one table.

ParameterDescriptionDefault
-ConfigPathPath to settings.ini<ScriptDir>\Config\settings.ini
-Version2019 | 2022 | 2025[General] DefaultVersion
-EditionEdition matching the version's edition list (e.g. Developer, Standard, Developer-Standard)DefaultEdition
-InstanceNameMSSQLServer (default instance) or a named instanceDefaultInstanceName
-CollationServer collationresolved collation
-ServiceAccount / -ServicePasswordSQL service account (DOMAIN\User + SecureString)virtual service account
-ServiceCredentialPSCredential (alternative to account/password)
-InstallDrive / -DataDrive / -LogDrive / -TempDrive / -BackupDriveOverride the disk layout (single letter each)from disk layout
-ComponentSSRS,SSAS,SSMS,SSIS,TDP (multi-select)enabled in settings.ini (SSMS+SSIS on by default)
-DriverJDBC,ODBC,DB2enabled ones with a source path
-MonitoringType0 = none, 1 = service, 2 = fullMonitoringDefault
-SkipPreInstallSkip PreInstall checks (automatic under -NonInteractive)
-SkipPostInstallSkip PostInstall
-AlwaysOnCreate an AG after PostInstall (Invoke-sqmAlwaysOnSetup)
-AvailabilityGroupName / -AgDatabase / -AgListenerName / -AgListenerIPAddress / -AgListenerPortAlwaysOn parameters (mostly auto-detected from the cluster)auto
-NonInteractiveFully unattended, no dialogs
-LogPathDirectory for the run logC:\System\WinSrvLog\MSSQL
-ProgressReportGenerate an animated HTML run replay
-ProgressReportPathTarget path for the HTML file<LogPath>\SqlSetup_<timestamp>.html
-WhatIfDry 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.

Execution flow

Nine steps, identical to the GUI.

  1. Admin checkImport modules (identical to Main.ps1).
  2. Resolve configurationGet-SetupConfig (settings.ini + domain profile) — CLI parameters override individual values.
  3. Dependency checkAssert-DbaToolsReady / Assert-sqmSQLToolReady.
  4. Resolve pathsGet-SqlPaths prints the plan (with -WhatIf, this is where it stops).
  5. PreInstall checksOptional, interactive only.
  6. InstallNew-SqlDirectoriesInvoke-SqlInstallation (= Install-DbaInstance).
  7. Components & driversOptional components (SSAS/SSRS/TDP/SSMS) and drivers (JDBC/ODBC/DB2).
  8. PostInstallInvoke-PostInstall (memory/TempDB/ports/monitoring/Ola/...).
  9. AlwaysOnIf -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

Full availability-group creation.

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

Live replay · Invoke-sqmAlwaysOnSetup · Server SQL01

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'
Examples

Three real invocations.

:: 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
Verification

How to know it actually worked.

Log & troubleshooting

Where to look when something's off.

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 codeMeaning
0OK
1No admin rights, or configuration missing
2Aborted by PreInstall
3Installation error
4A 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).