Skip to content

Update-DbaMaintenanceSolution do not update to the latest version. #10377

@frodr1k

Description

@frodr1k

Summarize Functionality

I had a sitdown with Ola this week and we used Update-DbaMaintenanceSolution to update some servers with a later version.

We realized I was still a couple of months behind which puzzled us a bit.

Upon investigating I realised that this codeblock actually searches for a cached copy first. Which if you as in my case forgot you ever run this command on this particular computer will cause you to install an outdated cached version.

`$localCachedCopy = Join-DbaPath -Path $dbatoolsData -Child 'sql-server-maintenance-solution-main'

if ($Force -or $LocalFile -or -not (Test-Path -Path $localCachedCopy)) {
# Ladda ner ny version
Save-DbaCommunitySoftware -Software MaintenanceSolution ...
}`

While I can see that using the cached version in some way would guarantee that you are using the same version. But if you are in a team, you can't trust that each member of the team is using the correct version anyway. The problem is that it acts as "install-if-not-cached" which is confusing for anyone without knowledge of the specifics of this code. Update-* commandlets should do what it says.

Better solution is to switch the logic. Always download the latest version and let -LocalFile be se source to point out older versions or perhaps for a bigger workshop point out the decided version. (Decided version cant be guaranteed anyway with the old cache behaviour.)

Is there a command that is similiar or close to what you are looking for?

Yes

Technical Details

Sugest code change should be something similar to this:

`if ($Force) {
Write-Message -Level Warning -Message "The -Force switch is no longer needed for Update-DbaMaintenanceSolution as it always downloads the latest version. It will be removed in a future release."
}

if ($LocalFile) {
Save-DbaCommunitySoftware -Software MaintenanceSolution -LocalFile $LocalFile -EnableException
} else {
Save-DbaCommunitySoftware -Software MaintenanceSolution -EnableException
}`

The -Force switch is stil honored but not really needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featuretriage requiredNew issue that has not been reviewed by maintainers

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions