Install-DbaCommunitySoftware - add unified community tooling installer (do Install-DbaCommunitySoftware) - #10565
Merged
Conversation
Adds the install-side counterpart to Save-DbaCommunitySoftware, which already unifies the download step behind one -Software parameter. One command now installs the Maintenance Solution, First Responder Kit, DarlingData, SqlWatch, sp_WhoIsActive and the DBA MultiTool, instead of six command names to remember. Each tool is dispatched to its own installer and the objects that installer emits are passed straight back, unshaped. Forwarding is worked out from the target's actual parameter list rather than a hardcoded map, so -Branch reaches only the three tools that have it and a warning names any selection it was dropped for. -Database and -Branch are forwarded only when explicitly bound, which leaves each installer on its own default otherwise. Two behaviors differ from calling an installer directly, both documented in the help: WhoIsActive is given master when Database is omitted, since it otherwise opens an interactive picker that would stall an unattended run, and a failure against one tool warns and continues rather than ending the batch. ShouldProcess is declared but deliberately not called at this level, so -WhatIf and -Confirm flow down to the installers and prompt once rather than twice. AzSqlTips is excluded on purpose. Save-DbaCommunitySoftware downloads it, but Invoke-DbaDbAzSqlTip consumes it as a query rather than installing procedures. (do Install-DbaCommunitySoftware) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Install-DbaSqlWatch is available everywhere, so saying SQLWATCH cannot be selected on Linux or macOS was wrong. public/ is dot-sourced wholesale and dbatools.psd1 exports the command unconditionally; the $script:windowsonly list it appears in is only read inside a PSVersion.Major -lt 5 branch, which never runs on 5.1 or 7. The missing-installer message covers a broken import, which is the case that can actually reach it. (do Install-DbaCommunitySoftware) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Install-DbaSqlWatch supports Windows PowerShell only, but its edition check sits in process while the download it needs runs in begin, so calling it from Core fetches the payload over the network and only then refuses. Selecting All from PowerShell Core paid for that on every run. SQLWATCH is now dropped before dispatch with a warning naming it, and the rest of the batch continues. Selecting it on its own stops with a clear message instead of silently doing nothing. Covered on Core with a real call, not a mock: SQLWATCH plus WhoIsActive warns and returns exactly the WhoIsActive row. (do Install-DbaCommunitySoftware) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…nces Every installer downloads its payload in begin and loops instances in process, so dispatching per instance fetched the same archive once per target - and with Force, redownloaded it every time. Collect instances in process and dispatch from end instead. Also drop SQLWATCH on PowerShell Core before the LocalFile count check, so losing it can leave a single tool holding the file rather than failing a selection that is no longer ambiguous, and reject a whitespace-only Database up front rather than quietly redirecting it to master. (do Install-DbaCommunitySoftware)
Absence of the downstream Core refusal message also fits a download that failed before it could warn, so check the SQLWATCH cache directory instead. Force makes Install-DbaSqlWatch refresh that directory unconditionally in begin, and Save-DbaCommunitySoftware deletes and recreates it, so an unchanged write time can only mean the installer was never entered. Verified the sentinel can trip. Also cover the whitespace Database guard, which ValidateNotNullOrEmpty lets through and the existing empty-string test never reached. (do Install-DbaCommunitySoftware)
…filter Dropping SQLWATCH on PowerShell Core left the guard counting survivors, so -Software SQLWATCH,WhoIsActive -LocalFile sqlwatch.zip saw one tool, passed, and handed the SqlWatch archive to Install-DbaWhoIsActive. Count what the caller asked for instead: an archive belongs to one named tool however many of them can run on this edition. Verified against the pre-fix code, where the call reached Install-DbaWhoIsActive and failed on its own LocalFile ValidateScript rather than on the guard. (do Install-DbaCommunitySoftware)
Member
Author
|
Mayyybe in 3.0, I'll make all the sub commands internal 🤔 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Adds
Install-DbaCommunitySoftware, the install-side counterpart toSave-DbaCommunitySoftware. That command already unifies the download step behind one-Softwareparameter; this does the same for installing, so you don't need to remember six separate command names.Install-DbaMaintenanceSolutionInstall-DbaFirstResponderKitInstall-DbaDarlingDataInstall-DbaSqlWatchInstall-DbaWhoIsActiveInstall-DbaMultiToolThe
-Softwarenames matchSave-DbaCommunitySoftwareso the download and install steps read the same way.Design notes
MaintenanceSolutionreturnsResultswith noDatabase/Name/Status,SQLWATCHreturnsDashboardPathand noName, andWhoIsActivecarries aVersion. All three variants are documented in.OUTPUTSrather than normalized away.-Branchreaches only the three tools that have one and a warning names any selection it was dropped from.-Databaseand-Branchforward only when explicitly bound, so each installer keeps its own default otherwise — notably SqlWatch, which defaults to theSQLWATCHdatabase and would be silently relocated by an unconditional-Database master.ShouldProcessis declared but not called at this level, so-WhatIf/-Confirmflow down and prompt once instead of twice.Save-DbaCommunitySoftwaredownloads it, butInvoke-DbaDbAzSqlTipconsumes it as a query rather than installing procedures.Two behaviors deliberately differ from calling an installer yourself, both documented in the help:
masterwhen-Databaseis omitted. Called directly with no database it opens an interactiveShow-DbaDbListpicker, which would stall an unattended run.Testing
18 tests, run against SQL Server 2022. 18 passed, 0 failed, 0 skipped.
Integration coverage spans multi-tool dispatch, single-tool pass-through, continuation past an unreachable instance (a real unreachable host ordered ahead of a live one — no mocks),
-Branchwarning, and-WhatIfasserting the side effect did not happen.Two edge cases are covered because they were live bugs during development:
-Database ""reachedInstall-DbaWhoIsActive's ownif (-not $Database)test and opened the interactive picker. Now rejected at binding.Select-Object -Uniquecompares case-sensitively on both 5.1 and 7, whileValidateSetaccepts any casing — so-Software WhoIsActive, whoisactiveinstalled twice and falsely tripped the single-tool-LocalFileguard. Deduplication is now case-insensitive and order-preserving.The WhoIsActive-defaults-to-master test never touches a
master.dbo.sp_WhoisActiveit did not create; it installs only when the procedure is absent and reports itself skipped otherwise, since an encrypted procedure has no recoverable definition and permissions do not survive a drop.Verified under both PowerShell 5.1 and 7.
Invoke-DbatoolsFormatterand PSScriptAnalyzer are clean.🤖 Generated with Claude Code