Skip to content

Commit fe79015

Browse files
Update-DbaInstance - Add early validation for empty -Path parameter
Adds a check in the begin block to stop with a clear error message when -Path is not provided and no default is configured via Set-DbatoolsConfig. Previously this resulted in a confusing "Cannot index into a null array" runtime error deep in the download logic. Fixes #10266 (do Update-DbaInstance) Co-authored-by: Andreas Jordan <andreasjordan@users.noreply.github.com>
1 parent 562e3ac commit fe79015

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

public/Update-DbaInstance.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ function Update-DbaInstance {
274274
}
275275
}
276276
}
277+
if (-not $Path) {
278+
Stop-Function -Category InvalidArgument -Message "Path is required. Please provide a -Path to a folder containing (or to store) SQL Server updates, or configure a default with Set-DbatoolsConfig -Name Path.SQLServerUpdates -Value 'C:\patches'."
279+
return
280+
}
277281
$actions = @()
278282
$actionTemplate = @{ }
279283
if ($InstanceName) { $actionTemplate.InstanceName = $InstanceName }

0 commit comments

Comments
 (0)